Jump to content

brizeljohn

New member
  • Posts

    1
  • Joined

  • Last visited

Personal Information

  • 3D printer
    Ultimaker S5

brizeljohn's Achievements

0

Reputation

  1. The ValueError: cannot convert float NaN to integer raised because of Pandas doesn't have the ability to store NaN values for integers. From Pandas v0.24, introduces Nullable Integer Data Types which allows integers to coexist with NaNs. This does allow integer NaNs . This is the pandas integer, instead of the numpy integer. So, use Nullable Integer Data Types (e.g. Int64). df['x'].astype('Int64') NB: You have to go through numpy float first and then to nullable Int32, for some reason. Another solution is Using numpy.nan_to_num(). The numpy.nan_to_num() returns an array or scalar replacing Not a Number ( Not A Number ) with zero, positive_infinity with a very large number and negative_infinity with a very small (or negative) number. If you are not satisfied with the above solutions, you need to say what you want to do with NANs . You can either drop those rows df.dropna() or replace nans with something else (0 for instance: df.fillna(0) )
×
×
  • Create New...