在执行列表理解时遇到错误

features_with_na=[features for features in df_main.columns if df_main[features].isna().sum()>1]

该列表理解应该为我提供所有缺少值的列。执行时,出现以下错误-

ValueError                                Traceback (most recent call last)
<ipython-input-26-0878dbe5183a> in <module>()
----> 1 features_with_na=[features for features in df_main.columns if df_main[features].isna().sum()>1]

1 frames
/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py in __nonzero__(self)
   1477     def __nonzero__(self):
   1478         raise ValueError(
-> 1479             f"The truth value of a {type(self).__name__} is ambiguous. "
   1480             "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
   1481         )

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

有任何想法吗?

评论