Sort pandas DataFrame by Multiple Columns in Python (Example) | Order Rows | sort_values() Function

Опубликовано: 25 Ноябрь 2022
на канале: Statistics Globe
728
14

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


На этой странице сайта вы можете посмотреть видео онлайн Sort pandas DataFrame by Multiple Columns in Python (Example) | Order Rows | sort_values() Function длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Statistics Globe 25 Ноябрь 2022, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 728 раз и оно понравилось 14 зрителям. Приятного просмотра!