Reputation: 15
I don't understand what is happening. It was working fine, and suddently, it's not. I got a dataframe looking like this:
And when I try to filter the indicators, the data is altered to things looking like this:
This is the code I use to filter the indicators and I expect to keep the same data
dfCountry = data.copy()
goodIndicators = ['GDP per capita (current US$)', 'Internet users (per 100 people)', 'other indicators']
dfCountry = dfCountry[dfCountry["Indicator Name"].isin(goodIndicators)]
Upvotes: 0
Views: 33
Reputation: 998
This is something that Pandas does with large or small numbers. It uses scientific notation. You could fix it by simply round your numbers. You could even add a number between the parentheses of the round
method to round to a specific number of decimals.
n_decimals = 0
df = df.round(n_decimals) # or df = df.round() since zero is default
You could also change the Pandas configuration. Change the number of decimals yourself that Pandas should show.
pd.set_option('display.float_format', lambda x: '%.5f' % x)
You could also just convert the float numbers to integers when you don't care about decimals.
for column in [c for c in df.columns if df.startswith('2')]:
df.loc[:, column] = df.loc[:, column].apply(int)
More about this Pandas notation.
Upvotes: 1