我有以下名为dfSocial的数据框:
row_number()
现在,我想制作一个新的数据框,如下所示:
select *
from (
select pr.name as product, pu.count, pr.price,
row_number() over(partition by s.id order by pu.purchasetime) rn
from purchase pu
inner join product pr on pr.id = pu.productid
inner join store s on s.id = pr.storeid
where pu.userid = ?
) t
where rn <= 3
任何人都可以帮助实现这一转变。 我尝试使用以下代码:
age gender impressions
0 13-17 female 234561
1 13-17 male 34574
2 25-34 female 120665
3 25-34 male 234560
4 35-44 female 5134
5 35-44 male 2405
6 45-54 female 423
7 45-54 male 324
无论该值是否为0,我们将不胜感激!