KDnuggets Home » News » 2019 » Aug » Tutorials, Overviews » 25 Tricks for Pandas ( 19:n29 )

25 Tricks for Pandas


Check out this video (and Jupyter notebook) which outlines a number of Pandas tricks for working with and manipulating data, covering topics such as string manipulations, splitting and filtering DataFrames, combining and aggregating data, and more.



Last week, Kevin Markham (@justmarkham) of DataSchool.io posted a handy video and an companion Jupyter notebook titled "My top 25 pandas tricks." I found the collection of tricks handy enough to warrant sharing with our readers.

True to its name, the video outlines a number of Pandas tricks for working with and manipulating data, covering topics such as string manipulations, splitting and filtering DataFrames, combining and aggregating data, and more. Aside from the promised 25 tricks, a bonus 26th covering Pandas DataFrame profiling is included.

The collection of tricks are well explained in the video, are practical and ready for use right away, and implementations with sample datasets can be studied further in the accompanying notebook.

If you aren't aware, Kevin is a data science educator and the founder of Data School, specializing in Python and machine learning. Data School is a website featuring blog posts, videos, courses, Jupyter notebooks, and webcast recordings, with a mix of free and paid content.

The Pandas DataFrame tricks from the video are:

  1. Show installed versions
  2. Create an example DataFrame
  3. Rename columns
  4. Reverse row order
  5. Reverse column order
  6. Select columns by data type
  7. Convert strings to numbers
  8. Reduce DataFrame size
  9. Build a DataFrame from multiple files (row-wise)
  10. Build a DataFrame from multiple files (column-wise)
  11. Create a DataFrame from the clipboard
  12. Split a DataFrame into two random subsets
  13. Filter a DataFrame by multiple categories
  14. Filter a DataFrame by largest categories
  15. Handle missing values
  16. Split a string into multiple columns
  17. Expand a Series of lists into a DataFrame
  18. Aggregate by multiple functions
  19. Combine the output of an aggregation with a DataFrame
  20. Select a slice of rows and columns
  21. Reshape a MultiIndexed Series
  22. Create a pivot table
  23. Convert continuous data into categorical data
  24. Change display options
  25. Style a DataFrame
  26. Bonus trick: Profile a DataFrame

Check out the Jupyter notebook for a more in-depth look at the Pandas tricks that Kevin lays out in the video. Also be sure to check out Data School for lots of other useful data science related learning content.

 
Related:


Sign Up

By subscribing you accept KDnuggets Privacy Policy