由于列数较多,我试图搜索列名中包含“el”的列名。这是我尝试过的代码
combined.columns.str.contains("el")
但是我得到的结果是一个 bool 数组,如何查看从中返回 true 的列名称。
最佳答案
使用boolean indexing
与 loc
使用 :
选择所有行:
combined.loc[:, combined.columns.str.contains("el")]
或者使用DataFrame.filter
:
combined.filter(like='el')
关于python - 如何查看str包含bool数组的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51836030/