I have a time series data frame and I count days of each month with the following code:
count_dates=df_inner.groupBy('dates').count().orderBy('dates')
This code gives me a new data frame with 1 column:
dates count
2021-03-01 5
2021-03-02 44
2021-03-03 3
2021-03-04 2
2021-03-05 1
This is another data frame:
name 2021-03-01 2021-03-02 2021-03-03 2021-03-04 2021-03-05
A 40 42 30 1 8
B 80 3 54 2 7
C 10 0 52 2 8
In other words, each date in the first dataset is a column in the other dataset. How I can divide each column of the second dataframe with the count column of the first df?
Output:
name 2021-03-01 2021-03-02 2021-03-03 2021-03-04 2021-03-05
A 40/5 42/44 30/3 1/2 8/5
B 80/5 3/44 54/3 2/2 7/5
C 10/5 0/44 52/3 2/2 8/5