Skip to content

Commit

Permalink
DOC: Improving docstring of pop method (pandas-dev#16416) (pandas-dev…
Browse files Browse the repository at this point in the history
  • Loading branch information
datapythonista authored and 3553x committed Jul 16, 2017
1 parent 4839111 commit d00cf3d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,43 @@ def swapaxes(self, axis1, axis2, copy=True):
def pop(self, item):
"""
Return item and drop from frame. Raise KeyError if not found.
Parameters
----------
item : str
Column label to be popped
Returns
-------
popped : Series
Examples
--------
>>> df = pd.DataFrame([('falcon', 'bird', 389.0),
... ('parrot', 'bird', 24.0),
... ('lion', 'mammal', 80.5),
... ('monkey', 'mammal', np.nan)],
... columns=('name', 'class', 'max_speed'))
>>> df
name class max_speed
0 falcon bird 389.0
1 parrot bird 24.0
2 lion mammal 80.5
3 monkey mammal NaN
>>> df.pop('class')
0 bird
1 bird
2 mammal
3 mammal
Name: class, dtype: object
>>> df
name max_speed
0 falcon 389.0
1 parrot 24.0
2 lion 80.5
3 monkey NaN
"""
result = self[item]
del self[item]
Expand Down

0 comments on commit d00cf3d

Please sign in to comment.