我正在尝试遍历一个数据框,其中列[myCol]存在空值。 我可以循环遍历数据框,但是当我指定只想查看空值时,就会出现错误。
最终目标是要强制将值放入空字段中,这就是为什么我首先进行迭代以识别它们的原因。
for index,row in df.iterrows():
if(row['myCol'].isnull()):
print('true')
AttributeError: 'str' object has no attribute 'isnull'
我尝试指定 column = 'None',因为当我打印数据帧的迭代时,这是我看到的值。但仍然没有成功:
for index,row in df.iterrows():
if(row['myCol']=='None'):
print('true')
No returned rows
非常感谢任何帮助!
if(row['myCol'] is None):
?否则这将与字符串“'None'”进行比较,而不是单例对象None
。 - hiro protagonistdf$myCol <- ifelse(df$myCol == "", df$FillInColumn, df$myCol)
。 - user5249203