简体   繁体   中英

pyspark dataframe count of where clause value is equals to

following is the sample dataframe

I have one column in with 'id' and i need new dataframe with count number considering where clause where vaule is equal to "number", new dataframe with vaule and count

source df and required newdf with count of df源 df 和需要的 newdf 以及 df 的计数

Any suggestions:

Just group by and count:

newdf = df.groupBy('Id').count()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM