Created
May 23, 2021 06:17
-
-
Save AayushSameerShah/d00397ebd114d013bb124735dccc3bf2 to your computer and use it in GitHub Desktop.
This snippet will give you an idea on how to sort values when it is in the group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
State District Population(values) | |
Guj Kutch 30 | |
Ahmedabad 100 | |
Surat 50 | |
Vadodra 20 | |
Jak 10 | |
Maha Mumbai 130 | |
Borri 10 | |
Pune 150 | |
UP Patna 20 | |
Gorakhpur 50 | |
Luckhnow 500 | |
''' | |
# Having this... if we need to sort in the group itself... | |
DF.sort_values() | |
# ↑ This will scramble all values | |
## THIS IS THE ONE ↓ ## | |
DF.sort_values().sort_index(index= 0, sort_remaining= False) | |
# ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ | |
# This part is so useful - Do it! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment