当前第2页 返回上一页
查询指定的行和列:
1 | student.ix[[ 0 , 2 , 4 , 5 , 7 ],[ 'Name' , 'Height' , 'Weight' ]].head()
|
查询所有女生的信息:
1 | student[student[ 'Sex' ] = = 'F' ]
|
查询出所有12岁以上的女生信息:
1 | student[(student[ 'Sex' ] = = 'F' ) & (student[ 'Age' ]> 12 )]
|
查询出所有12岁以上的女生姓名、身高和体重:
1 | student[(student[ 'Sex' ] = = 'F' ) & (student[ 'Age' ]> 12 )][[ 'Name' , 'Height' , 'Weight' ]]
|
上面的查询逻辑其实非常的简单,需要注意的是,如果是多个条件的查询,必须在&(且)或者|(或)的两端条件用括号括起来。
以上就是实例讲解Python如何利用pandas查询数据的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
Python中end=' '是什么意思
趣味玩转——用Python分析《三国演义》中的社交网络
Python单引号和双引号的区别
Python基础入门--函数
Python怎么读文件
Python如何停止运行
解析Python新型字符串格式漏洞及解决方案
基于rabbitmq rpc实现的主机管理
Python 匹配url中是否存在ip地址的方法
Python版简单工厂模式的介绍
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 实例讲解Python如何利用pandas查询数据