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

Method test_pop

pandas/tests/frame/methods/test_pop.py:12–34  ·  view source on GitHub ↗
(self, float_frame)

Source from the content-addressed store, hash-verified

10
11class TestDataFramePop:
12 def test_pop(self, float_frame):
13 float_frame.columns.name = "baz"
14
15 float_frame.pop("A")
16 assert "A" not in float_frame
17
18 float_frame["foo"] = "bar"
19 float_frame.pop("foo")
20 assert "foo" not in float_frame
21 assert float_frame.columns.name == "baz"
22
23 # gh-10912: inplace ops cause caching issue
24 a = DataFrame([[1, 2, 3], [4, 5, 6]], columns=["A", "B", "C"], index=["X", "Y"])
25 b = a.pop("B")
26 b += 1
27
28 # original frame
29 expected = DataFrame([[1, 3], [4, 6]], columns=["A", "C"], index=["X", "Y"])
30 tm.assert_frame_equal(a, expected)
31
32 # result
33 expected = Series([2, 5], index=["X", "Y"], name="B") + 1
34 tm.assert_series_equal(b, expected)
35
36 def test_pop_non_unique_cols(self):
37 df = DataFrame({0: [0, 1], 1: [0, 1], 2: [4, 5]})

Callers

nothing calls this directly

Calls 4

popMethod · 0.95
DataFrameClass · 0.90
SeriesClass · 0.90
popMethod · 0.45

Tested by

no test coverage detected