In this video, learn how to use stack().
- [Teacher] When using the stack function, the stack function returns a data frame or a series. And notice that you will never have any any values or missing data because by default the drop any flag is equal to true. The inner levels of a stack function are sorted. So when we do a stack we are returning a data frame or series with a new innermost level of rules. So the hundred meters and the two hundred meters which are the inner most columns are dragged down and if there's 100 or 200 meter that corresponds to each male or female athlete then this is listed.
To help you remember the stack function, I try and visualize whether I want to make this data frame taller or wider. If I want to make the data frames taller, then I need to use the stack function because stacking gives you a taller data frame. Let's head over to the Jupiter notebook to look at stacking. Now remember that our original data frame is called DF and if we then us the stack function we are going to end up with the taller or longer data frame. So df.stack and we can see that the corresponding data frame that's been generated is taller.
Now in the real world, I prefer to actually specify which column I'm going to be using in the stacking function. So I would normally say df.stack and specify the event and I'll get exactly the same data frame. In the next video, we'll cover unstack.
- Working with plots
- Boolean indexing
- String handling
- Grouping data
- Creating your own colormaps
Skill Level Intermediate
1. Technical Setup
2. Series and DataFrames
3. Data Input and Validation
4. Basic Analysis
5. Basic Plotting
9. Data Visualizations
Next steps1m 1s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.