code: def test_shift_with_periodindex(self, frame_or_series):
      # Shifting with PeriodIndex
      ps = DataFrame(
          np.arange(4, dtype=float),
          index=pd.period_range("2020-01-01", periods=4),
      )
      ps = tm.get_obj(ps, frame_or_series)
  
      shifted = ps.shift(1)
      unshifted = shifted.shift(-1)
      tm.assert_index_equal(shifted.index, ps.index)
      tm.assert_index_equal(unshifted.index, ps.index)
      if frame_or_series is DataFrame:
          tm.assert_numpy_array_equal(
              unshifted.iloc[:, 0].dropna().values,
              ps.iloc[:-1, 0].values,
          )
      else:
          tm.assert_numpy_array_equal(
              unshifted.dropna().values, ps.values[:-1]
          )
  
      shifted2 = ps.shift(1, "D")
      shifted3 = ps.shift(1, offsets.Day())
      tm.assert_equal(shifted2, shifted3)
      tm.assert_equal(ps, shifted2.shift(-1, "D"))
  
      msg = "does not match PeriodIndex freq"
      with pytest.raises(ValueError, match=msg):
          ps.shift(freq="W")
  
      # legacy support
      shifted4 = ps.shift(1, freq="D")
      tm.assert_equal(shifted2, shifted4)
  
      shifted5 = ps.shift(1, freq=offsets.Day())
      tm.assert_equal(shifted5, shifted4)
  
imports: import numpy
  import pytest
  import pandas
  from pandas import CategoricalIndex, DataFrame, Index, NaT, Series, date_range, offsets
  import pandas._testing
label_desc: Use image node_id 15 for calling the TestDataFrameShift obj's underlying member method code with example usage: obj.test_shift_with_periodindex(frame_or_series) without return types