pandasql

发现了个不错的库, 可以将sql外挂到pandas的数据结构上,
直接写sql, 不用麻烦去记各种API了


In [10]: import pandasql

In [11]: from pandas import Series, DataFrame

In [12]: data = {"name":["yahoo","google","facebook"], "marks":[200,400,800], "price":[9, 3, 7]}

In [13]: f1 = DataFrame(data)

In [14]: pandasql.sqldf('select name, count(*) from f1 where marks!=200 group by name', globals())
Out[14]: 
       name  count(*)
0  facebook         1
1    google         1

https://zhuanlan.zhihu.com/p/25630700

你可能感兴趣的:(pandasql)