I want to follow along but

Screen Link:

From the beginning of the instructions:

We’ve already created a dataframe named regions containing all of the countries and corresponding regions from the happiness2015, happiness2016, and happiness2017 dataframes.

I was wondering if there were steps to recreate regions, I like to follow along in my own Jupyter Notebook so I was hoping to get the same exact data.

If this is supposed to be a teaching moment though I understand. Thanks!

Hi @mctopherganesh

To create regions you have different options, that you will see later in the course:

  1. Concatenate: Basically you add the data from happiness2016 and happiness2017 into the end of happiness2015 or in a new df and it’s done with pd.concat()
    example:
    regions = pd.concat([happiness2015, happiness2016, happiness2017], ignore_index=True)

  2. Merge: Instead of adding the columns at the end of the df, it combines them according to a specific column and it’s done with df.merge()
    example:
    happiness2015.merge(happiness2016, left_on:column, right_on:column)

  3. Join: Similar to merge, it works exactly like joins in SQL, it’s done with df.join(). The huge difference is that in this case the index needs to be similar
    example:
    happiness2015.join(happiness2016, how='left', on=column)

This pandas page does a better explanation and recomends when to use each one of them

Good luck!

2 Likes

:star_struck:

@alegiraldo666 thank you!