How to order the rows of a pandas DataFrame based on multiple columns in the Python programming language. More details: https://statisticsglobe.com/sort-pand...
Python code of this video:
import pandas as pd # Import pandas library in Python
data = pd.DataFrame({'x1':range(0, 8), # Create example DataFrame
'x2':['C', 'A', 'B', 'C', 'A', 'A', 'B', 'A'],
'x3':['a', 'b', 'c', 'b', 'c', 'b', 'a', 'c']})
print(data) # Print example DataFrame
data_new = data.sort_values(['x2', 'x3']) # Sort DataFrame
print(data_new) # Print new DataFrame
Follow me on Social Media:
Facebook – Statistics Globe Page: / statisticsglobecom
Facebook – R Programming Group for Discussions & Questions: / statisticsglobe
Facebook – Python Programming Group for Discussions & Questions: / statisticsglobepython
LinkedIn – Statistics Globe Page: / statisticsglobe
LinkedIn – R Programming Group for Discussions & Questions: / 12555223
LinkedIn – Python Programming Group for Discussions & Questions: / 12673534
Twitter: / joachimschork
Music by bensound.com
On this page of the site you can watch the video online Sort pandas DataFrame by Multiple Columns in Python (Example) | Order Rows | sort_values() Function with a duration of hours minute second in good quality, which was uploaded by the user Statistics Globe 25 November 2022, share the link with friends and acquaintances, this video has already been watched 728 times on youtube and it was liked by 14 viewers. Enjoy your viewing!