Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created January 31, 2018 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/77e94b133086995a8747da4853b00824 to your computer and use it in GitHub Desktop.
Save Fhernd/77e94b133086995a8747da4853b00824 to your computer and use it in GitHub Desktop.
Aplicar funciones a un objeto DataFrame en Python.
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