I used python code:
df.stat.crosstab("age", "y").orderBy("age_y").show()
to create a crosstab from a spark dataframe as follows:
However, I cannot find a code to obtain the row percentages. For example, age 18 row percentages should be 5/12 = 41.7% for 'no' and 7/12 = 58.3% for 'yes'. The sum of 2 percentages is 100%.
May someone advise me in this case? Many thanks in advance.
