This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> pd.read_csv("custom_dt_fmt.csv", parse_dates=["date"], infer_datetime_format=True) | |
date category balance | |
0 Jan_01_2022 A 100 | |
1 Feb_02_2022 B 200 | |
2 Mar_12_2022 C 300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> df_cols = pd.read_csv("dates_text_cols.csv", parse_dates={"date": ["y", "m", "d"]}) | |
>>> df_cols | |
date category balance | |
0 2022-01-01 A 100 | |
1 2022-02-02 B 200 | |
2 2022-03-12 C 300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> df = pd.read_csv("dates_text.csv", parse_dates=["date"]) | |
>>> df.dtypes | |
date datetime64[ns] | |
category object | |
balance int64 | |
dtype: object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import pandas as pd | |
>>> df = pd.read_csv("dates_text.csv") | |
>>> df.dtypes | |
date object | |
category object | |
balance int64 | |
dtype: object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pywebio import input as pin | |
from pywebio import output as pout | |
pout.put_code("""pin.input("What's your favorite fruit?")""") | |
pin.input("What's your favorite fruit?") | |
pout.put_code("""pin.slider("How old are you?", min_value=0, max_value=120)""") | |
pin.slider("How old are you?", min_value=0, max_value=120) | |
pout.put_code("""pin.checkbox("What toppings for pizza?", options=["pepperoni", "sausage", "chicken"])""") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# what you run: | |
sns.set_theme() | |
# the actual function signature: | |
set_theme(context="notebook", style="darkgrid", palette="deep", | |
font="sans-serif", font_scale=1, color_codes=True, rc=None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def any_like_fruit_break(fruits, liked_fruit): | |
liked = False | |
for fruit in fruits: | |
print(f"Checking {fruit} likable") | |
if fruit == liked_fruit: | |
liked = True | |
break | |
print("Found liked") | |
return liked |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def any_liked_fruit(fruits, liked_fruit): | |
liked = False | |
for fruit in fruits: | |
print(f"Checking {fruit} likable") | |
if not liked and fruit == liked_fruit: | |
liked = True | |
print("Found liked") | |
return liked | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> def taking_larger_square(s1, s2): | |
... return s1 * s1 if s1.sum() > s2.sum() else s2 * s2 | |
>>> df0.combine(df1.rename(columns={"c": "a", "d": "b"}), taking_larger_square) | |
a b | |
0 4 25 | |
1 9 36 | |
2 16 49 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import pandas as pd | |
>>> df0 = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) | |
>>> df0 | |
a b | |
0 1 4 | |
1 2 5 | |
2 3 6 | |
>>> df1 = pd.DataFrame({"c": [2, 3, 4], "d": [5, 6, 7]}) | |
>>> df1 | |
c d |