社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

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 ),使用函数比使用循环更好