Hello, I have the following data frame.
score
0 0.0
1 9.0
2 NaN
3 1.0
4 4.0
... ...
211 10.0
212 4.0
213 1.0
214 6.0
215 3.0
It's in float form, but I wanted to get rid of the decimal point in integer form, so I tried to convert it to int type, but there was a missing value, so I got an error. I have to visualize it, so it has to be numeric, so is there a way to get rid of the decimal point?
python pandas
I didn't upload the code, so I'm only telling you the approximate direction.
In general, int ('str object') causes an error if the object is a non-numeric character.
For this, you should refer to the following methods.
try:
n = int(a)
except:
n = 0
Use fillna to change to a specific value (for example, -1000) and convert the column to an integer. After that, you can change the specific value that you changed nan back to the desired value and deal with it.
© 2024 OneMinuteCode. All rights reserved.