Created
November 10, 2021 06:09
-
-
Save patrickbrus/c7e1c29f189010710d2d6ba98344f38f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compute GDP by using GDP per capita and the Population columns | |
df_final["GDP"] = df_final["GDP per capita"] * df_final["Population"] | |
# Remove % sign of Population under 20 years old column and convert it to be of type float | |
def transform_col(col_val): | |
try: | |
return float(col_val.replace(" %", "")) | |
except: # value is NaN | |
return col_val | |
df_final["Population under 20 years old in %"] = df_final["Population under20 years old"].apply(transform_col) | |
df_final = df_final.drop(columns=["Population under20 years old"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment