1

I have a pandas dataframe which looks like this:

df

I now want to get the column Predictions to an int value in order to plot the data. How could I do this?

1
  • 1
    df['Predictions'].str[0].astype(int) Commented Dec 30, 2020 at 18:25

1 Answer 1

1

It just a list comprehension from pandas columns

you can use

df['Predictions'].str[0].astype(int)

to extract decimal values

df['Predictions'].str[0]-df['Predictions'].str[0].astype(int)
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! Is there a possibility to keep the comma values?
Glad to help, if you just want decimal values, you can use df['Predictions'].str[0]-df['Predictions'].str[0].astype(int)

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.