I have a pyspark dataframe. It is a movie dataset. One column is the genres split by |. Each movie has multiple genres.
genres = spark.sql("SELECT DISTINCT genres FROM movies ORDER BY genres ASC")
genres.show(5)
I would like to count each genre has how many movies. And I also want to show what are those movies. Just like the following:

How should I do this?