code: def test_indexing():
      idx = date_range("2001-1-1", periods=20, freq="ME")
      ts = Series(np.random.default_rng(2).random(len(idx)), index=idx)
  
      # getting
  
      # GH 3070, make sure semantics work on Series/Frame
      result = ts["2001"]
      tm.assert_series_equal(result, ts.iloc[:12])
  
      df = DataFrame({"A": ts})
  
      # GH#36179 pre-2.0 df["2001"] operated as slicing on rows. in 2.0 it behaves
      #  like any other key, so raises
      with pytest.raises(KeyError, match="2001"):
          df["2001"]
  
      # setting
      ts = Series(np.random.default_rng(2).random(len(idx)), index=idx)
      expected = ts.copy()
      expected.iloc[:12] = 1
      ts["2001"] = 1
      tm.assert_series_equal(ts, expected)
  
      expected = df.copy()
      expected.iloc[:12, 0] = 1
      df.loc["2001", "A"] = 1
      tm.assert_frame_equal(df, expected)
  
imports: from datetime import datetime, timedelta
  import re
  from dateutil.tz import gettz, tzutc
  import numpy
  import pytest
  import pytz
  from pandas._libs import index
  import pandas
  from pandas import DataFrame, Series, Timestamp, date_range, period_range
  import pandas._testing
label_desc: Use image node_id 12 for calling a global function with example usage: test_indexing() without return types