python - 使用熊猫过滤 Excel 列
问题描述
我有 5 列,但我只想要列 A = Override 的行
A 列 B 列等... 覆盖 xxxx 矩阵 xxxx
正确过滤列 A 的正确语法是什么?
解决方案
以下将删除名称与“覆盖”不同的列。
import pandas as pd
#read in dataframe
df = pd.read_excel(path_to_df)
cols_name = df.columns.tolist()
for col in cols_name:
if df[col] is not df['Override']:
del df[col]
推荐阅读
- sql - 如何根据行值将列总数添加到我的 oracle 视图中
- python - `hookwrapper` 对`py.test` 钩子意味着什么?
- eclipse - 在 Eclipse 产品中指定默认主题不起作用
- azure - 如何以编程方式生成/获取指向 Azure 门户的资源链接?
- python - python - 从列表中构造嵌套字典
- excel - 如何在工作簿(但不是 ActiveWorkbook)中获取选定的选项卡?
- angular - Angular 2+ textarea 占位符条件和翻译
- java - JComboBox 将与泛型类型数组列表一起使用吗?
- c# - 代理服务器 vs 主机文件 vs 防火墙,哪个以编程方式阻止 C# 中的网站?
- ios - UITableViewCell 只有在某个区域被按下时才会被选中