Skip to content

Commit 7749d9b

Browse files
committed
DOC: Replace @appender with inline docstring for DataFrame.items
- Removed @appender decorator from DataFrame.items() method - Inlined the complete docstring directly into the method - Addresses issue #62437 to improve docstring clarity and standardization
1 parent 8476e0f commit 7749d9b

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

pandas/core/frame.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,8 +1472,54 @@ def style(self) -> Styler:
14721472
Name: population, dtype: int64
14731473
"""
14741474

1475-
@Appender(_shared_docs["items"])
14761475
def items(self) -> Iterable[tuple[Hashable, Series]]:
1476+
"""
1477+
Iterate over (column name, Series) pairs.
1478+
1479+
Iterates over the DataFrame columns, returning a tuple with
1480+
the column name and the content as a Series.
1481+
1482+
Yields
1483+
------
1484+
label : object
1485+
The column names for the DataFrame being iterated over.
1486+
content : Series
1487+
The column entries belonging to each label, as a Series.
1488+
1489+
See Also
1490+
--------
1491+
DataFrame.iterrows : Iterate over DataFrame rows as
1492+
(index, Series) pairs.
1493+
DataFrame.itertuples : Iterate over DataFrame rows as namedtuples
1494+
of the values.
1495+
1496+
Examples
1497+
--------
1498+
>>> df = pd.DataFrame({'species': ['bear', 'bear', 'marsupial'],
1499+
... 'population': [1864, 22000, 80000]},
1500+
... index=['panda', 'polar', 'koala'])
1501+
>>> df
1502+
species population
1503+
panda bear 1864
1504+
polar bear 22000
1505+
koala marsupial 80000
1506+
>>> for label, content in df.items():
1507+
... print(f'label: {label}')
1508+
... print(f'content: {content}', sep='\n')
1509+
...
1510+
label: species
1511+
content:
1512+
panda bear
1513+
polar bear
1514+
koala marsupial
1515+
Name: species, dtype: object
1516+
label: population
1517+
content:
1518+
panda 1864
1519+
polar 22000
1520+
koala 80000
1521+
Name: population, dtype: int64
1522+
"""
14771523
for i, k in enumerate(self.columns):
14781524
yield k, self._ixs(i, axis=1)
14791525

0 commit comments

Comments
 (0)