我有一個一維資料框:
東風:
feat1 feat2 feat3 ... featn
0 0.12 0.002 0.53 0.23
我想過濾其值大于 0.2 的所有列:
df[df.iloc[0] > 0.2]
所需的輸出:
feat3 ... featn
0 0.53 0.23
但我收到一個錯誤:
pandas.core.indexing.IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match).
uj5u.com熱心網友回復:
進行布爾切片時,需要與行長度匹配的串列/系列,這會過濾行。
顯式子集列:
df.loc[:, df.iloc[0] > 0.2]
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/406338.html
標籤:
下一篇:為什么日期格式不斷變化?
