Assignment No.3

Use this thread is for asking and answering questions related to Assignment 3.
Hope you guys have a nice day :slight_smile:

countries_df['new_column'] = something

countries_df['gdp'] = "population"*"continent"
I’m doing this but its not working.

Why are you multiplying two strings?
You should multiply columns from countries_df.

1 Like

Understood. Thanks!!

i got overall life expectancy = 72.7216. any comments whether it’s matching your answer or not ?

1 Like

can anyone help me with .isna question ?
how to properly use that function ?

I having issues doing the groupby for this question in the assignment. Can somebody help?

Q. Create a data frame that counts the number countries in each continent?

country_counts_df = countries_df[‘location’].groupby([‘continent’) or even using countries_df.continent within the group by clause.

country_counts_df = countries_df[‘location’].groupby([‘continent’,‘location’], axis=0, dropna=True)

I wrote like this >>>> covid_data_df.isna().sum().total_tests.
In my view this find the total number of Nan values which will be summed in every column and from that column list, I picked total_tests which gives answer 122. That means 122 countries have missed total tests values.

1 Like

Can anyone help me on last two optional questions of assignment 3?

You need to merge the two data frames on location. You will get the common countries that appear in both lists.

Once try countries_df[‘continent’].groupby()

Try this
*countries_df[‘gdp’] = countries_df[‘population’]countries_df[‘gdp_per_capita’]

1 Like

@aakashns
In assignment 3 Q: Create a data frame that counts the number countries in each continent?
Whenever i try to create a dataframe it creates a series with single column of ‘location’ and index ‘continent’. How to create a dataframe or this output will work(since in the question it says to create a dataframe)?

Hello Sid,

Try this countries_df.groupby([‘continent’]).size().to_frame()

1 Like

Yes, I got the same as 72.72165193409664

I’m stuck…what is the formula…