Suppose you have Apple and Facebook stock data in a single row with many repeating columns per stock symbol like below.
So basically you want to separate this into 2 rows, one for Apple stock and the other for Facebook stock.
Here is the step to achieve this
- Select columns only related to Apple stock
- Gather Columns and create key and value column
- Clean up Column names (remove AAPL.quote.)
- Create a branch data frame from the source step
- On the branch, Select columns only related to Facebook stock.
- Clean up Column names (remove FB.quote.)
- On the branch, Gather Columns and create key and value column
- merge the main data frame (Apple) and the branch data frame (Facebook)
- Spread the key and value
10 Now you have two rows one for Apple stock and the other for Facebook
You can download EDF file from here to see Data Wrangling details.