Answer to Question #305430 in Python for john

Question #305430

1.    Count and display the country which is a member of the EU (EU = yes) and not a member of the EU (EU = no).


1
Expert's answer
2022-03-03T09:59:44-0500
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()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS