python - 如何在 Pandas 中删除带有空标题的列?

标签 python pandas

如果我有一个 DF:

Name1 Name2 NUll Name3 NULL Name4
abc   abc        null       abc
abc   abc        null       abc
abc   abc        null       abc
abc   abc        null       abc

我可以使用 dropna 将 Name3 保留为包含所有空值的列吗?但仍然删除两个 Null 列。 谢谢

最佳答案

使用 DataFrame.drop 怎么样? ?

In [3]: df = pd.read_clipboard()
Out[3]: 
  Name1 Name2  NUll Name3  NULL  Name4
0   abc   abc        null          abc
1   abc   abc        null          abc
2   abc   abc        null          abc
3   abc   abc        null          abc

In [4]: df.drop(["NUll", "NULL"], axis=1)
Out[4]: 
  Name1 Name2 Name3  Name4
0   abc   abc  null    abc
1   abc   abc  null    abc
2   abc   abc  null    abc
3   abc   abc  null    abc

关于python - 如何在 Pandas 中删除带有空标题的列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39733141/

相关文章:

python - 扭曲了centos缺少mail.smtp?

python - Pandas Excel合并单元格解析重命名未命名列

python - 复制训练示例以处理 pandas 数据框中的类不平衡

python - Django / python : email reply is updated to site

python - 从两个日期列填充按月数据框

python - 合并具有来自一个数据帧的相似数据的列

python - 使用正则表达式改变数字 Pandas

python - Groupby Sum 忽略几列

python - Pandas Groupby 中过去 12 个月的唯一值

python - 使用 ctypes 的回调(如何从 C 调用 python 函数)