(temp_hdfstore)
| 392 | |
| 393 | |
| 394 | def test_create_table_index(temp_hdfstore): |
| 395 | store = temp_hdfstore |
| 396 | |
| 397 | def col(t, column): |
| 398 | return getattr(store.get_storer(t).table.cols, column) |
| 399 | |
| 400 | # data columns |
| 401 | df = DataFrame( |
| 402 | np.random.default_rng(2).standard_normal((10, 4)), |
| 403 | columns=Index(list("ABCD")), |
| 404 | index=date_range("2000-01-01", periods=10, freq="B"), |
| 405 | ) |
| 406 | df["string"] = "foo" |
| 407 | df["string2"] = "bar" |
| 408 | store.append("f", df, data_columns=["string", "string2"]) |
| 409 | assert col("f", "index").is_indexed is True |
| 410 | assert col("f", "string").is_indexed is True |
| 411 | assert col("f", "string2").is_indexed is True |
| 412 | |
| 413 | # specify index=columns |
| 414 | store.append("f2", df, index=["string"], data_columns=["string", "string2"]) |
| 415 | assert col("f2", "index").is_indexed is False |
| 416 | assert col("f2", "string").is_indexed is True |
| 417 | assert col("f2", "string2").is_indexed is False |
| 418 | |
| 419 | # try to index a non-table |
| 420 | store.put("f2", df) |
| 421 | msg = "cannot create table index on a Fixed format store" |
| 422 | with pytest.raises(TypeError, match=msg): |
| 423 | store.create_table_index("f2") |
| 424 | |
| 425 | |
| 426 | def test_create_table_index_data_columns_argument(temp_hdfstore): |
nothing calls this directly
no test coverage detected