Author: Bill Tubbs
I got a warning when executing the following line of code:
df['population'] = df['population'] * 1e3
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
I think the warning is something to do with the fact that the object on the left is a copy of the DataFrame.
I think the correct code is:
df.loc[:, 'population'] = df['population'] * 1e3