Pivoting columns to rows
Data is often produced by systems in what the engineers building the system thought was the most efficient manner. Rarely do data processing and storage systems store data with visualization in mind. Similarly, you may have data available that is appropriate for one type of visualization but not another. In this recipe, we'll look at a sales dataset. This dataset has sales revenue values per category. The categories are Electronics, Groceries, and Household Appliances. Each of the categories has its own column, which prevents us from easily making a line chart with overall revenue. To resolve this, we're going to pivot the data such that these three individual columns become a single Category column, and values are placed in a single Revenue column.
Getting ready
To follow along with this recipe, download the Sample Files 6.1 folder from this book's GitHub repository.
How to do it…
Start by opening the Sales Data.csv file from...