Sorting Data in Python With pandas (Summary)
You now know how to use two core methods of the pandas library: .sort_values()
and .sort_index()
. With this knowledge, you can perform basic data analysis with a DataFrame. While there are a lot of similarities between these two methods, seeing the difference between them makes it clear which one to use for different analytical tasks.
In this video course, you’ve learned how to:
- Sort a pandas DataFrame by the values of one or more columns
- Use the
ascending
parameter to change the sort order - Sort a DataFrame by its
index
using.sort_index()
- Organize missing data while sorting values
- Sort a DataFrame in-place using
inplace
set toTrue
For more information on concepts covered in this course, you can check out:
- The pandas DataFrame: Working With Data Efficiently
- Discover bpython: A Python REPL With IDE-Like Features
- bpython
- Introduction to Sorting Algorithms in Python
- pandas documentation
- Combining Data in pandas With merge(), .join(), and concat()
- Using pandas to Make a Gradebook in Python
- Sorting Data With Python
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:00
Summary. Well done! You’ve made it to the end of this course. You now know how to use two core methods at the pandas
library: .sort_values()
and .sort_index()
. With this knowledge, you can perform basic data analysis with a DataFrame.
00:17
While there are a lot of similarities between these two methods, seeing the difference between them makes it clear which one to choose for different analytical tasks. In this course, you’ve learned how to sort a pandas DataFrame by the values of one or more columns, use the ascending
parameter to change the sort order, sort a DataFrame by its index using .sort_index()
, organize missing data while sorting values, and sort a DataFrame in-place using inplace
set to True
.
00:50 These methods are a large part of being proficient with data analysis. They’ll help you build a strong foundation on which you can perform more advanced pandas operations.
01:00 If you want to see some examples of more advanced uses of pandas sort methods, then the pandas documentation is a great resource.
01:08 We hope you found this course useful, and we’ll see you again soon at realpython.com.
Become a Member to join the conversation.