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’'错误解决方案
代码如下所示
import pandas as pd
import numpy as np
df = pd.read_excel('data011_content.xlsx')
for i in range(len(df)):
try:
if np.isnan(df['E'][i]):
date_str = df['发布时间'][i]
这一段代码导致的问题
np.isnan(df['E'][i])
df['E'][i]里面的内容是字符串,报错提示输入类型的问题,因此我换了pandas的
pd.isna(data['A'][i])
完美解决问题