-1
I have a column of notes in string format. They come as follows: 432432.0 Always comes with . 0 then I wanted to go straight to int and not to float As ta in this format I saw that I should first convert to float and then to int Only that there are some lines that had the string "Unknown" that I previously changed everything to None Then when I turn the conversation from float to int of this error:
ValueError: Cannot convert non-finite values (NA or inf) to integer
I can solve this error with this modification here:
thereof:
data['Score-9'] = data['Score-9'].astype(int)
for that reason:
data['Score-9'] = data['Score-9'].fillna(0).astype(int)
but I don’t want None’s gaps to be 0 because that’s gonna change the averages, medians and the like. How can I do the conversion by continuing with None and without error?
I believe you add the average to
nanwill affect average and fashion. The question should be what to do with "Unknown". If they should be ignored, replace them withnp.nan, for this import the numpy (import numpy as np). With this: a series1, nan, 3would average = 2.– Paulo Marques