Created
February 1, 2018 02:11
-
-
Save Fhernd/f48faced9adb3cf5ea6e21a6d0d6aae8 to your computer and use it in GitHub Desktop.
Recorrer los 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 | |
import numpy as np | |
df = pd.DataFrame({'uno': [1, 2, 3], 'dos': [4, 5, 6], 'tres': [7, 8, 9]}, index=['x', 'y', 'z']) | |
# Iteración por columnas del DataFrame: | |
for col in df: | |
print(df[col].mean()) | |
print() | |
# Iteración por filas del DataFrame: | |
for indice_fila, fila in df.iterrows(): | |
print(indice_fila) | |
print(fila) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment