Advertisement
Fhernd

recorrer-columas-filas.py

Jan 31st, 2018
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. import pandas as pd
  2. import numpy as np
  3.  
  4. df = pd.DataFrame({'uno': [1, 2, 3], 'dos': [4, 5, 6], 'tres': [7, 8, 9]}, index=['x', 'y', 'z'])
  5.  
  6. # Iteración por columnas del DataFrame:
  7. for col in df:
  8.     print(df[col].mean())
  9.    
  10. print()
  11.  
  12. # Iteración por filas del DataFrame:
  13. for indice_fila, fila in df.iterrows():
  14.     print(indice_fila)
  15.     print(fila)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement