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

Function test_select_columns_in_where

pandas/tests/io/pytables/test_select.py:27–54  ·  view source on GitHub ↗
(temp_hdfstore)

Source from the content-addressed store, hash-verified

25
26
27def test_select_columns_in_where(temp_hdfstore):
28 # GH 6169
29 # recreate multi-indexes when columns is passed
30 # in the `where` argument
31 index = MultiIndex(
32 levels=[["foo", "bar", "baz", "qux"], ["one", "two", "three"]],
33 codes=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
34 names=["foo_name", "bar_name"],
35 )
36
37 # With a DataFrame
38 df = DataFrame(
39 np.random.default_rng(2).standard_normal((10, 3)),
40 index=index,
41 columns=["A", "B", "C"],
42 )
43
44 temp_hdfstore.put("df", df, format="table")
45 expected = df[["A"]]
46
47 tm.assert_frame_equal(temp_hdfstore.select("df", columns=["A"]), expected)
48
49 tm.assert_frame_equal(temp_hdfstore.select("df", where="columns=['A']"), expected)
50
51 # With a Series
52 s = Series(np.random.default_rng(2).standard_normal(10), index=index, name="A")
53 temp_hdfstore.put("s", s, format="table")
54 tm.assert_series_equal(temp_hdfstore.select("s", where="columns=['A']"), s)
55
56
57def test_select_with_dups(temp_hdfstore):

Callers

nothing calls this directly

Calls 5

MultiIndexClass · 0.90
DataFrameClass · 0.90
SeriesClass · 0.90
putMethod · 0.80
selectMethod · 0.45

Tested by

no test coverage detected