Created
January 31, 2018 00:54
-
-
Save Fhernd/cbbf973bc10a67f2a0811ef87f10aad5 to your computer and use it in GitHub Desktop.
Ordenar datos de un DataFrame en Python.
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
import pandas as pd | |
df = pd.DataFrame({'uno': [1, 2, 3], 'dos': [4, 5, 6], 'tres': [7, 8, 9]}, index=['x', 'y', 'z']) | |
print(df) | |
print() | |
# Orden por índice (fila): | |
print(df.sort_index()) | |
print() | |
# Ordenar por índice (columna): | |
print(df.sort_index(axis=1, ascending=False)) | |
print() | |
# Ordenar por los valores de la columna 'tres': | |
print(df.sort_values(by='tres', ascending=False)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment