当前第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统计不同字符的个数
Python怎么安装tensorflow
Python实现蒙特卡罗方法(代码示例)
分享Python如何实现头像拼接技术/
笔记之 Python正则表达式
Python如何做excel自动化
Python如何实现爬取需要登录的网站代码实例
Python里fd是什么意思
Python中numpy的广播原则的代码解析
Python输入一个数n如何判断是否为素数
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 实例讲解Python如何利用pandas查询数据