解决TypeError: ufunc ‘isnan‘ not supported for the input types, and the inputs could not be safely coe

解决TypeError: ufunc ‘isnan’ not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ‘‘safe’’

报错代码
print(np.isnan(data).any())
报错日志
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
报错原因

数据列的类型不一致

print(data.info())
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 96453 entries, 0 to 96452
Data columns (total 12 columns):
 #   Column                    Non-Null Count  Dtype              
---  ------                    --------------  -----              
 0   Formatted Date            96453 non-null  datetime64[ns, UTC]
 1   Summary                   96453 non-null  object             
 2   Precip Type               95936 non-null  object             
 3   Temperature (C)           96128 non-null  float64            
 4   Apparent Temperature (C)  96384 non-null  float64            
 5   Humidity                  96431 non-null  float64            
 6   Wind Speed (km/h)         95156 non-null  float64            
 7   Wind Bearing (degrees)    94189 non-null  float64            
 8   Visibility (km)           96003 non-null  float64            
 9   Loud Cover                0 non-null      float64            
 10  Pressure (millibars)      95165 non-null  float64            
 11  Daily Summary             96453 non-null  object             
dtypes: datetime64[ns, UTC](1), float64(8), object(3)
memory usage: 8.8+ MB

按数据类型单独处理,例如上述数据分为datetime64,float64,object

欢迎大家交流学习,任何问题都可以留言
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值