test_get.py 662 B

123456789101112131415161718192021222324252627
  1. import pytest
  2. from pandas import DataFrame
  3. import pandas._testing as tm
  4. class TestGet:
  5. def test_get(self, float_frame):
  6. b = float_frame.get("B")
  7. tm.assert_series_equal(b, float_frame["B"])
  8. assert float_frame.get("foo") is None
  9. tm.assert_series_equal(
  10. float_frame.get("foo", float_frame["B"]), float_frame["B"]
  11. )
  12. @pytest.mark.parametrize(
  13. "df",
  14. [
  15. DataFrame(),
  16. DataFrame(columns=list("AB")),
  17. DataFrame(columns=list("AB"), index=range(3)),
  18. ],
  19. )
  20. def test_get_none(self, df):
  21. # see gh-5652
  22. assert df.get(None) is None