Created
January 31, 2018 11:53
-
-
Save Fhernd/77e94b133086995a8747da4853b00824 to your computer and use it in GitHub Desktop.
Aplicar funciones a un objeto 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 | |
import numpy as np | |
df = pd.DataFrame({'uno': [1, 2, 3], 'dos': [4, 5, 6], 'tres': [7, 8, 9]}, index=['x', 'y', 'z']) | |
# Aplica la función promedio a todas las filas: | |
print(df.apply(np.mean)) | |
# Apica la función promedio a todas las columnas: | |
print(df.apply(np.mean, axis=1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment