Skip to content

Instantly share code, notes, and snippets.

View AayushSameerShah's full-sized avatar
🤨
Hmm...

Aayush Shah AayushSameerShah

🤨
Hmm...
View GitHub Profile
from wordcloud import WordCloud, STOPWORDS
text = ' '.join(df_movie['listed_in'])
plt.rcParams['figure.figsize'] = (12,12)
wordcloud = WordCloud(background_color = 'black',colormap='vlag', width = 1200, height = 1200, max_words = 121).generate(text)
plt.imshow(wordcloud)
plt.axis('off')
plt.show()
@AayushSameerShah
AayushSameerShah / Gredient.py
Created May 11, 2021 11:57
Gredient Color in Plot
from matplotlib import cm
color = cm.inferno_r(np.linspace(.4, .8, 18))
plt.plot(color= color)
@AayushSameerShah
AayushSameerShah / bar_values.py
Created May 11, 2021 13:06
Text on Graph (Bar values)
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))
@AayushSameerShah
AayushSameerShah / Global_font.py
Last active June 5, 2021 07:38
Setting global font settings ...
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
@AayushSameerShah
AayushSameerShah / Cool_shaded_region.py
Created May 12, 2021 13:50
This will give the shaded region in a graph... main part is under # Make shaded region comment
# 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)
@AayushSameerShah
AayushSameerShah / categorize_multiple.py
Created May 17, 2021 15:44
This is the process when you find yourself in a situation when there are overlapping categories per row and still one to categorize by single category... This will help to do just that and is so simple.
# 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] = []
@AayushSameerShah
AayushSameerShah / Fees_buss.py
Created May 19, 2021 14:01
This is the short form for your reminder
for i in range(50):
print("Fizz" * (i % 3 == 0) + "Buzz" * (i % 5 == 0) or False)
@AayushSameerShah
AayushSameerShah / Pandas Usefuls.py
Last active May 23, 2021 06:07
This gist presents various mini-time savers pandas snippets
# 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(
@AayushSameerShah
AayushSameerShah / Pandas Usefuls2.py
Last active May 23, 2021 06:10
This is the second version of pandas usefuls... enjoy
# 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)
@AayushSameerShah
AayushSameerShah / sort_grouped.py
Created May 23, 2021 06:17
This snippet will give you an idea on how to sort values when it is in the group
'''
State District Population(values)
Guj Kutch 30
Ahmedabad 100
Surat 50
Vadodra 20
Jak 10
Maha Mumbai 130