MCPcopy
hub / github.com/pandas-dev/pandas / pop

Method pop

pandas/core/frame.py:6495–6546  ·  view source on GitHub ↗

Return item and drop it from DataFrame. Raise KeyError if not found. Parameters ---------- item : label Label of column to be popped. Returns ------- Series Series representing the item that is dropped. See A

(self, item: Hashable)

Source from the content-addressed store, hash-verified

6493 )
6494
6495 def pop(self, item: Hashable) -> Series:
6496 """
6497 Return item and drop it from DataFrame. Raise KeyError if not found.
6498
6499 Parameters
6500 ----------
6501 item : label
6502 Label of column to be popped.
6503
6504 Returns
6505 -------
6506 Series
6507 Series representing the item that is dropped.
6508
6509 See Also
6510 --------
6511 DataFrame.drop: Drop specified labels from rows or columns.
6512 DataFrame.drop_duplicates: Return DataFrame with duplicate rows removed.
6513
6514 Examples
6515 --------
6516 >>> df = pd.DataFrame(
6517 ... [
6518 ... ("falcon", "bird", 389.0),
6519 ... ("parrot", "bird", 24.0),
6520 ... ("lion", "mammal", 80.5),
6521 ... ("monkey", "mammal", np.nan),
6522 ... ],
6523 ... columns=("name", "class", "max_speed"),
6524 ... )
6525 >>> df
6526 name class max_speed
6527 0 falcon bird 389.0
6528 1 parrot bird 24.0
6529 2 lion mammal 80.5
6530 3 monkey mammal NaN
6531
6532 >>> df.pop("class")
6533 0 bird
6534 1 bird
6535 2 mammal
6536 3 mammal
6537 Name: class, dtype: str
6538
6539 >>> df
6540 name max_speed
6541 0 falcon 389.0
6542 1 parrot 24.0
6543 2 lion 80.5
6544 3 monkey NaN
6545 """
6546 return super().pop(item=item)
6547
6548 def _replace_columnwise(
6549 self, mapping: dict[Hashable, tuple[Any, Any]], inplace: bool, regex

Callers 10

_get_series_listMethod · 0.95
readMethod · 0.95
test_popMethod · 0.95
test_popFunction · 0.95
evalMethod · 0.45

Calls

no outgoing calls

Tested by 7

test_popMethod · 0.76
test_popFunction · 0.76