1

I have a csv file that contains 6 columns in such format:

2021-04-13 11:03:13+02:00,3.0,3.0,3.0,12.0,12.0

Now I want to remove the decimal point of each column except for the first one.

I already tried using df.style.format aswell as the df.astype(int) and pd.set_option('precision', 0) but in the latter two it always gets stuck on the first column, since that doesn't quiet fit ( ValueError: invalid literal for int() with base 10: '2021-04-13 11:03:13+02:00' )

Any help would be much appreciated!

1 Answer 1

1

With your shown samples, please try following. Using iloc functionality of pandas.

df.iloc[:,1:] = df.iloc[:,1:].astype(int)

df will be as follows after running above code:

0,2021-04-13 11:03:13+02:00,3,3,3,12,12
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.