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

Publicado em: 25 Novembro 2022
no canal de: 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


Nesta página do site você pode assistir ao vídeo on-line Sort pandas DataFrame by Multiple Columns in Python (Example) | Order Rows | sort_values() Function duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Statistics Globe 25 Novembro 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 728 vezes e gostou 14 espectadores. Boa visualização!