From the course: pandas Essential Training
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Sorting a DataFrame or Series
From the course: pandas Essential Training
Sorting a DataFrame or Series
- [Instructor] If you've found yourself staring at a jumbled mess of data, wishing there was an easy way to bring order to the chaos, then the sort_values method is your friend. You can arrange your data alphabetically or numerically to start with. So this is our DataFrame with three random indexes or rows, and let's sort by the athlete name. And you can see that we're sorting by the surname, and so we've got Edgar and Arvo Ossian and so on. Now let's take a look at what the type is for this output. And you can see visually that this is a series. Now what you can also do is to sort by athlete name for the entire DataFrame. So you do oo.sort_values and then you specify which column you're looking to sort by. And here, you can see, again, that we've got the entire DataFrame here and we're sorting by the athlete names that we saw earlier. So that's Abbye, Edgar and Aaltonen, Arvo and so on. And you can see that this is in fact a DataFrame and you can confirm that visually because this…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Get an overview of the data and displaying it8m 23s
-
(Locked)
Select a Series (column)4m 51s
-
(Locked)
Challenge: Fundamentals55s
-
(Locked)
Solution: Fundamentals6m 16s
-
(Locked)
Python lists and dictionaries2m 2s
-
(Locked)
Rename a Series (or column)5m 56s
-
(Locked)
Remove a Series (column) or row8m 39s
-
(Locked)
Filtering rows for a single condition3m 46s
-
(Locked)
Filter rows for multiple conditions4m 6s
-
(Locked)
Using String methods4m 32s
-
(Locked)
Sorting a DataFrame or Series4m 18s
-
-
-
-
-