![]() ![]() where ever data is not present, it represents as null by default. This will transpose the countries from DataFrame rows into columns and produces the below output. PivotDF = df.groupBy("Product").pivot("Country").sum("Amount") To get the total amount exported to each country of each product, will do group by Product, pivot by Country, and the sum of Amount. It is an aggregation where one of the grouping columns values is transposed into individual columns with distinct data. PySpark SQL provides pivot() function to rotate the data from one column into multiple columns.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |