Python 需要额外的转置方法
在寻找如何检查NaN值的答案时,我发现了这个堆栈溢出帖子 我用了霍布斯的答案。但不管有没有最后的转置方法,我都得到了完全相同的结果Python 需要额外的转置方法,python,pandas,transpose,Python,Pandas,Transpose,在寻找如何检查NaN值的答案时,我发现了这个堆栈溢出帖子 我用了霍布斯的答案。但不管有没有最后的转置方法,我都得到了完全相同的结果 nan_rows = df[df.isnull().T.any().T] nan_rows = df[df.isnull().T.any()] 两条语句返回的行完全相同。 提到的答案有额外的T有什么具体原因吗?我认为我们不需要在末尾添加一个T,因为df.isnull().T.any()给出了一个pd.Series df.isnull().T.any() Out
nan_rows = df[df.isnull().T.any().T]
nan_rows = df[df.isnull().T.any()]
两条语句返回的行完全相同。
提到的答案有额外的T有什么具体原因吗?我认为我们不需要在末尾添加一个
T
,因为df.isnull().T.any()
给出了一个pd.Series
df.isnull().T.any()
Out[33]:
0 False
1 True
2 True
dtype: bool
df.isnull().T.any().T
Out[34]:
0 False
1 True
2 True
dtype: bool
为什么不呢
df.isnull().any(axis = 1)
Out[37]:
0 False
1 True
2 True
dtype: bool