私信  •  关注

yhn

yhn 最近创建的主题
yhn 最近回复了
3 年前
回复了 yhn 创建的主题 » 使用python根据条件提取数据

你可以试试这个:

import pandas as pd
d = {'col1': [1, 2], 'col2': [3, 4], 'col3': [3, 4]}
df = pd.DataFrame(data=d)
print(df)
print(df[(df['col1']==1) & (df['col2']==3)])

结果: enter image description here

-----------或者--------

尝试在以下位置使用熊猫功能:( link to pandas.where tuto ),使用函数比使用循环更好