-
-
Save drorata/f6652f326b828e6def914a04ea532be8 to your computer and use it in GitHub Desktop.
Pivot a dataframe directly using Spark SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
* | |
FROM | |
( | |
SELECT | |
date_format (tpep_pickup_datetime, 'EEEE') AS day_of_week, | |
fare_amount, | |
passenger_count | |
FROM | |
data | |
) PIVOT ( | |
{agg_func}(fare_amount) FOR day_of_week IN ( | |
'Monday', | |
'Tuesday', | |
'Wednesday', | |
'Thursday', | |
'Friday', | |
'Saturday', | |
'Sunday' | |
) | |
) | |
ORDER BY | |
passenger_count; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment