Pandas Dataframe의 다양한 iteration 방법 비교

yeoni·2023년 5월 8일
0
post-custom-banner

>>> df = pd.DataFrame({'num_legs': [4, 2], 'num_wings': [0, 2]},
...                   index=['dog', 'hawk'])
>>> df
      num_legs  num_wings
dog          4          0
hawk         2          2
>>> for row in df.itertuples():
...     print(row)
...
Pandas(Index='dog', num_legs=4, num_wings=0)
Pandas(Index='hawk', num_legs=2, num_wings=2)

Reference
1) https://inmoonlight.github.io/2021/02/04/Pandas-Dataframe-iterations/
2) https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.itertuples.html

profile
데이터 사이언스 / just do it
post-custom-banner

0개의 댓글