test_insert.py 482 B

123456789101112131415161718
  1. import numpy as np
  2. import pytest
  3. from pandas import (
  4. NaT,
  5. PeriodIndex,
  6. period_range,
  7. )
  8. import pandas._testing as tm
  9. class TestInsert:
  10. @pytest.mark.parametrize("na", [np.nan, NaT, None])
  11. def test_insert(self, na):
  12. # GH#18295 (test missing)
  13. expected = PeriodIndex(["2017Q1", NaT, "2017Q2", "2017Q3", "2017Q4"], freq="Q")
  14. result = period_range("2017Q1", periods=4, freq="Q").insert(1, na)
  15. tm.assert_index_equal(result, expected)