test_pickle.py 692 B

1234567891011121314151617181920212223242526
  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. from pandas.tseries import offsets
  10. class TestPickle:
  11. @pytest.mark.parametrize("freq", ["D", "M", "A"])
  12. def test_pickle_round_trip(self, freq):
  13. idx = PeriodIndex(["2016-05-16", "NaT", NaT, np.NaN], freq=freq)
  14. result = tm.round_trip_pickle(idx)
  15. tm.assert_index_equal(result, idx)
  16. def test_pickle_freq(self):
  17. # GH#2891
  18. prng = period_range("1/1/2011", "1/1/2012", freq="M")
  19. new_prng = tm.round_trip_pickle(prng)
  20. assert new_prng.freq == offsets.MonthEnd()
  21. assert new_prng.freqstr == "M"