pandas.DataFrame.items
- DataFrame.items()[source]
-
Перебор пар (имя столбца, Series).
Перебирает столбцы DataFrame, возвращая кортеж с именем столбца и содержанием в виде Series.
- Возвращает:
-
- label:object
-
Имена столбцов для итерируемого DataFrame.
- content:Series
-
Элементы столбца, относящиеся к каждому метке, в виде Series.
См. также
DataFrame.iterrows-
Перебор строк DataFrame как пар (индекс, Series).
DataFrame.itertuples-
Перебор строк DataFrame как именованных кортежей значений.
Примеры
>>> df = pd.DataFrame({'species': ['bear', 'bear', 'marsupial'], ... 'population': [1864, 22000, 80000]}, ... index=['panda', 'polar', 'koala']) >>> df species population panda bear 1864 polar bear 22000 koala marsupial 80000 >>> for label, content in df.items(): ... print(f'label: {label}') ... print(f'content: {content}', sep='\n') ... label: species content: panda bear polar bear koala marsupial Name: species, dtype: object label: population content: panda 1864 polar 22000 koala 80000 Name: population, dtype: int64
© 2008–2022, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.2.2/reference/api/pandas.DataFrame.items.html