Roosevelt H
Roosevelt H

Reputation: 340

How do I remove extra zeros in a dataframe column?

I got a dataframe that contains data looking like:

 Date         Values
2016-12-31    13000000.0
2017-12-31   -45000000.0
2018-12-31   -129000000.0
2019-12-31    276000000.0

Is there a way to remove the last 3 zeros before the decimal point? So for example in the values column. the value is 13000000.0 I would like to remove 3 zeros so the number becomes: 13000.0 Any help would be greatly appreciated.

Upvotes: 0

Views: 90

Answers (2)

Eric M
Eric M

Reputation: 1418

To remove 3 zeros you need to divide the column by 1000:

df['Values'] = df['Values'] / 1e3

Upvotes: 3

Michel Guimarães
Michel Guimarães

Reputation: 411

Try this:

df['Values'] = df['Values'] / 1000 

Upvotes: 1

Related Questions