Reshaping and pivoting
In some cases, you'll want to make some more radical transformations to your dataset. In this section, we'll learn how to reshape an Optimus DataFrame in various ways, including pivoting, staking, and melting.
Pivoting
Pivoting is the process of reshaping stacked data into a new dataframe with simpler and less detailed data. It involves using the data of a column of choice and using it as column labels. Then, you must use one or more columns to group the data and calculate its values with the preferred summarization or aggregation over the rest of the data. The following is an example of this:
Let's look at an example of a dataset of sales that was made in a short period of time:
df = op.create.dataframe({ "date": ["1/1/21", "1/1/21", "1/2/21", "1/2/21", "1/3/21", "1/3/21", "...