Dataframe python中的sql查询

sc4hvdpw  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(163)

我想在pandas Dataframe 上执行此sql脚本,以获取premoteid在不同cremoteid中出现的次数。

SELECT count(distinct cremoteid), sr.premoteid
FROM sales_ranking sr
JOIN storesales_hourly sh ON sh.premoteid = sr.premoteid
group by sr.premoteid

我试过:

df.groupby(['premoteid']).unique()["cremoteid"].count()

但我得到了这个错误:

'DataFrameGroupBy' object has no attribute 'unique'

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题