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.isna().any(1) |
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
''' | |
State District Population(values) | |
Guj Kutch 30 | |
Ahmedabad 100 | |
Surat 50 | |
Vadodra 20 | |
Jak 10 | |
Maha Mumbai 130 |
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
# 1. Describe... some more | |
DF.describe(include= ['dtype']) | |
# 2. Use the freaking .str.contains() | |
DF.col.str.contains() | |
# 3. Format for a while! (COOLEST) | |
pd.set_option('display.float_format', '{:,}'.format) |
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
# 1. Use of .agg in groupy | |
DF.groupby('').agg(['mean', 'max']) | |
# or | |
DF.groupby('').agg({'col1:': 'max', | |
'col2': 'min'}) | |
# 2. Amazing, when using agg from above or other, if | |
# you want to rename the columns ON THE AIR, then... | |
DF.groupby('').agg( |
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
for i in range(50): | |
print("Fizz" * (i % 3 == 0) + "Buzz" * (i % 5 == 0) or False) |
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
# Create a unique set, so it becomes clear | |
genres = set() | |
for gen in df.Genre: | |
for single_gen in map(str.strip, gen.split(",")): | |
genres.add(single_gen) | |
# Create dict to store ids of that category | |
genre_ids = dict() | |
for gen in genres: | |
genre_ids[gen] = [] |
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
# SIMPLE chhe, Don't worry... | |
def func(x): | |
return x ** 2 | |
x = np.linspace(0, 10) | |
y = func(x) | |
fig, ax = plt.subplots() | |
ax.plot(x, y, 'r', linewidth=2) | |
ax.set_ylim(bottom=0) |
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
rcParams['font.family'] = 'sans-serif' | |
rcParams['font.sans-serif'] = ['Tahoma'] | |
COLOR = 'blue' | |
mpl.rcParams['text.color'] = COLOR | |
mpl.rcParams['axes.labelcolor'] = COLOR | |
mpl.rcParams['xtick.color'] = COLOR | |
mpl.rcParams['ytick.color'] = COLOR |
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
x = ["A", "B", "C", "D"] | |
y = [1, 2, 3, 4] | |
plt.barh(x, y) | |
for index, value in enumerate(y): | |
plt.text(value, index, str(value)) |
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 matplotlib import cm | |
color = cm.inferno_r(np.linspace(.4, .8, 18)) | |
plt.plot(color= color) |