| SQL | Pandas |
|---|---|
| select * from airports | airports |
| select * from airports limit 3 | airports.head(3) |
| select id from airports where ident = ‘KLAX’ | airports[airports.ident == ‘KLAX’].id |
| select distinct type from airport | airports.type.unique() |
| SQL | Pandas |
|---|---|
| select * from airports where iso_region = ‘US-CA’ and type = ‘seaplane_base’ | airports[(airports.iso_region == ‘US-CA’) & (airports.type == ‘seaplane_base’)] |
| select ident, name, municipality from airports where iso_region = ‘US-CA’ and type = ‘large_airport’ | airports[(airports.iso_region == ‘US-CA’) & (airports.type == ‘large_airport’)][[‘ident’, ‘name’, ‘municipality’]] |
| SQL | Pandas |
|---|---|
| select * from airport_freq where airport_ident = ‘KLAX’ order by type | airport_freq[airport_freq.airport_ident == ‘KLAX’].sort_values(‘type’) |

本文介绍了如何利用pandas库来实现SQL查询的功能,详细探讨了如何将SQL查询语句转换为pandas的数据操作。
最低0.47元/天 解锁文章

2959

被折叠的 条评论
为什么被折叠?



