code: def test_first_last_raises(self, frame_or_series):
      # GH#20725
      obj = DataFrame([[1, 2, 3], [4, 5, 6]])
      obj = tm.get_obj(obj, frame_or_series)
  
      msg = "'first' only supports a DatetimeIndex index"
      with tm.assert_produces_warning(
          FutureWarning, match=deprecated_msg
      ), pytest.raises(
          TypeError, match=msg
      ):  # index is not a DatetimeIndex
          obj.first("1D")
  
      msg = "'last' only supports a DatetimeIndex index"
      with tm.assert_produces_warning(
          FutureWarning, match=last_deprecated_msg
      ), pytest.raises(
          TypeError, match=msg
      ):  # index is not a DatetimeIndex
          obj.last("1D")
  
file_path: pandas/pandas/tests/frame/methods/test_first_and_last.py
imports: import numpy
  import pytest
  import pandas
  from pandas import DataFrame, Index, bdate_range, date_range
  import pandas._testing
label_desc: Use image node_id 2 for calling the TestFirst obj's underlying member method code with example usage: obj.test_first_last_raises(frame_or_series) without return types