python - Pandas not recognizing NaN as null -
i have dataframe, portion of looks this:
i read in file using line of code:
df = pd.read_table(oname,skiprows=1,sep='\t',usecols=(3,4,5),names=['year','month','snow_depth'])
when call df.isnull(), false each cell when nan should come true default, believe. have idea why isn't getting picked on?
edit: results of df.info()
<class 'pandas.core.frame.dataframe'> int64index: 360 entries, 516 875 data columns (total 3 columns): year 360 non-null int64 month 360 non-null int64 snow_depth 360 non-null object dtypes: int64(2), object(1) memory usage: 11.2+ kb
it looks data had 'nan'
values ' nan'
can add param read_table
, na_values=[' nan']
, add default list of values treat nan
.
alternatively can replace
them using:
df.replace(' nan', np.nan)
Comments
Post a Comment