1. Count and display the country which is a member of the EU (EU = yes) and not a member of the EU (EU = no).
import pandas as pd
dic = {'countries': ['England', 'France', 'Brazil', 'Germany', 'Portugal', 'Italy'], 'Population': [5000000, 2000000, 500000, 2500000, 1000000, 3000000], 'membership': ['yes', 'yes', 'no', 'yes', 'yes', 'yes'], 'no_per_cities': [100, 85, 25, 78, 52, 68], 'coast_line': ['yes', 'yes', 'no','yes', 'yes','yes'] }
df = pd.DataFrame(dic)
#Count and display the country which is a member of the EU (EU = yes) and not a member of the EU (EU = no).
df[df['membership'] == 'yes']['countries']
df[df['membership'] == 'yes']['countries'].count()
df[df['membership'] == 'no']['countries']
df[df['membership'] == 'no']['countries'].count()
Comments
Leave a comment