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

Function test_remove

pandas/tests/io/pytables/test_store.py:525–566  ·  view source on GitHub ↗
(temp_hdfstore)

Source from the content-addressed store, hash-verified

523
524
525def test_remove(temp_hdfstore):
526 store = temp_hdfstore
527 ts = Series(
528 np.arange(10, dtype=np.float64), index=date_range("2020-01-01", periods=10)
529 )
530 df = DataFrame(
531 1.1 * np.arange(120).reshape((30, 4)),
532 columns=Index(list("ABCD")),
533 index=Index([f"i-{i}" for i in range(30)]),
534 )
535 store["a"] = ts
536 store["b"] = df
537 store.remove("a")
538 assert len(store) == 1
539 tm.assert_frame_equal(df, store["b"])
540
541 store.remove("b")
542 assert len(store) == 0
543
544 # nonexistence
545 with pytest.raises(
546 KeyError, match="'No object named a_nonexistent_store in the file'"
547 ):
548 store.remove("a_nonexistent_store")
549
550 # pathing
551 store["a"] = ts
552 store["b/foo"] = df
553 store.remove("b/foo")
554 assert len(store) == 1
555
556 store["a"] = ts
557 store["b/foo"] = df
558 store.remove("b")
559 assert len(store) == 1
560
561 # __delitem__
562 store["a"] = ts
563 store["b"] = df
564 del store["a"]
565 del store["b"]
566 assert len(store) == 0
567
568
569def test_same_name_scoping(temp_hdfstore):

Callers

nothing calls this directly

Calls 7

SeriesClass · 0.90
date_rangeFunction · 0.90
DataFrameClass · 0.90
IndexClass · 0.90
reshapeMethod · 0.45
removeMethod · 0.45
raisesMethod · 0.45

Tested by

no test coverage detected