(temp_hdfstore)
| 25 | |
| 26 | |
| 27 | def 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 | |
| 57 | def test_select_with_dups(temp_hdfstore): |
nothing calls this directly
no test coverage detected