I have a table DF look like below
ID Days
1 30
2 55
3 32
4 12
5 100
.....
and I want to get a count as below:
month count
30 days and greater 20,000
60 days and greater 15,323
90 days and greater 11,232
.....
3600 days and greater 55
my code is really simple and straighforward, I just applied filter for each month, and get counts, then I copied and paste into Excel, such as below:
month1 = df.filter("Days >= 30").agg(countDistinct('ID')).show()
month2 = df.filter("Days>= 60").agg(countDistinct('ID')).show()
month3 = df.filter("Days >= 90").agg(countDistinct('ID')).show() ....
which is really not efficient.
I wonder if there is any easier way to do it? and create a table just like that.
Thanks at advanced!