Home > Software design >  How can I change a column of numbers in excel that all have 2 decimal points on python?
How can I change a column of numbers in excel that all have 2 decimal points on python?

Time:10-07

So I have a column of numbers on excel that for some reason have 2 decimal points such as

1033.000000.0

all of the numbers in the column end with a ".0"

I want to import the csv of the dataframe which has this column (lets say col3) and change it in python.

I wouldnt even know how to approach this. Do I have to scan though each of the numbers and remove the second instance of a fullstop? is there a simple way to do this? the dataframe is very large.

CodePudding user response:

basically, a for loop:

example:

for row in col3:
    x = row.rsplit(".", 1)
    print(x)

rsplit() splits the number by the right side

and the for should be for all the rows in the csv that you want to find

the first argument is what is looking for to "split" the number and the second one is how many times it has to look for it

  • Related