Skip to content

Instantly share code, notes, and snippets.

View ChaitanyaBaweja's full-sized avatar

Chaitanya Baweja ChaitanyaBaweja

View GitHub Profile
temp = {"123":{"H":1,"B":2},
"456":{"H":1, "B":1}
}
data = {"event": [
{ "id":"123",
"H":[{"name":3,
"label":2}
],
"B": [{"name":3,
# defining our venn
v = venn2(subsets=(1,1,1), set_labels = ('Set A', 'Set B'))
# setting color of id 11 to purple
v.get_patch_by_id('11').set_color('purple')
#setting label of id 10 to New Text
v.get_label_by_id('10').set_text('New Text')
#plot title
plt.title('Customizing Venn using IDs')
# defining our venn
venn2(subsets = (50, 20, 10), set_labels = ('Set A', 'Set B'));
# adding outline with width 3 and style dashed
venn2_circles(subsets = (50, 20, 10), linewidth=3, linestyle='dashed');
# defining a venn
venn2(subsets = (50, 20, 10), set_labels = ('Set A', 'Set B'));
# adding an outline
venn2_circles(subsets = (50, 20, 10));
# Taking a union of all sets
fire_safety= English | French | Math | Science
#Plotting alongside English and French
venn3([English, French, fire_safety], set_labels = ('English', 'French','Fire-Safety'))
plt.title('Relationship b/w students taking English, French and Fire-Safety Class\n')
# using Science instead of Math
venn3([English, French, Science], set_labels = ('English Class', 'French Class','Science Class'))
# plot title
plt.title('Relationship b/w students taking English, French and Science Class\n')
# use venn3 when you have three groups
venn3([English, French, Math], set_labels = ('English Class', 'French Class','Maths Class'))
# plot title
plt.title('Relationship b/w students taking English, French and MathsClass\n')
# adding labels using set_labels parameter
venn2([English, French], set_labels = ('English Class', 'French Class'))
# plot title
plt.title('Relationship b/w students taking English and French Class\n')
#Import libraries
from matplotlib_venn import venn2, venn2_circles
from matplotlib_venn import venn3, venn3_circles
from matplotlib import pyplot as plt
# defining sets for both subjects
English = {'John', 'Amy', 'Howard', 'Lucy', 'Alice', 'George', 'Jacob', 'Rajesh', 'Remy', 'Tom'}
French = {'Arthur', 'Leonard', 'Karan', 'Debby', 'Bernadette', 'Alice', 'Ron', 'Penny', 'Sheldon', 'John'}
# drop all rows with atleast one NaN
new_df = df.dropna(axis = 0, how ='any')
# drop all rows with all NaN
new_df = df.dropna(axis = 0, how ='all')
# drop all columns with atleast one NaN
new_df = df.dropna(axis = 1, how ='any')
# drop all columns with all NaN