I think this is a really easy question but I just wanted to clarify.
Do you have to continuously rename a dataframe when changing it?
df18gdp = df18[df18.series=='GDP (current US$)']
df18gdp = df18gdp.drop(columns = 'series')
df18gdp = df18gdp.set_index('country')
df18gdp = df18gdp.drop(index = ['World', 'Low income', 'Middle income', 'High income'])
df18gdp = df18gdp.sort_values('2018', ascending=False)
Could I simply do the following?
Is there a smoother way of making changes like this??
Constantly saying 'df18gdp=' seems redundant
df18gdp = df18[df18.series=='GDP (current US$)']
df18gdp.drop(columns = 'series')
df18gdp.set_index('country')
df18gdp.drop(index = ['World', 'Low income', 'Middle income', 'High income'])
df18gdp.sort_values('2018', ascending=False)
Thank you