# 识别python中DataFrame中的nan
for i in pfsj.index:
  if type(pfsj.loc[i]['WZML']) == float:
    print('float value is ${}'.format(pfsj.loc[i]['WZML']))
  elif type(pfsj.loc[i]['WZML']) == str:
    print('str value is ${}'.format(pfsj.loc[i]['WZML']))

结果:

Python中识别DataFrame中的nan

# 根据结果可知在DataFrame中,nan的类型为float
# 使用math中的isnan函数识别数据是否是nan类型的
for i in pfsj.index:
  if type(pfsj.loc[i]['WZML']) == float:
    if isnan(pfsj.loc[i]['WZML']):
      print('float type is ${}'.format(type(pfsj.loc[i]['WZML'])))

结果:

Python中识别DataFrame中的nan

 

相关文章:

  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 1970-01-01
  • 2022-12-23
猜你喜欢
  • 2023-01-19
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-13
  • 2022-01-23
相关资源
相似解决方案