Answers for "cannot convert float nan to integer"

0

cannot convert float nan to integer

# x contained NaN
df = df[~df['x'].isnull()]

# Y contained some other garbage, so null check was not enough
df = df[df['y'].str.isnumeric()]

# final conversion now worked
df[['x']] = df[['x']].astype(int)
df[['y']] = df[['y']].astype(int)
Posted by: Guest on October-06-2021

Code answers related to "cannot convert float nan to integer"

Browse Popular Code Answers by Language