code: def test_asof(self):
      pser = pd.Series(
          [1, 2, np.nan, 4], index=[10, 20, 30, 40], name="Koalas"
      )
      psser = ps.from_pandas(pser)
  
      self.assert_eq(psser.asof(20), pser.asof(20))
      self.assert_eq(
          psser.asof([5, 20]).sort_index(),
          pser.asof([5, 20]).sort_index(),
      )
      self.assert_eq(psser.asof(100), pser.asof(100))
      self.assert_eq(repr(psser.asof(-100)), repr(pser.asof(-100)))
      self.assert_eq(
          psser.asof([-100, 100]).sort_index(),
          pser.asof([-100, 100]).sort_index(),
      )
  
      # where cannot be an Index, Series or a DataFrame
      self.assertRaises(
          ValueError, lambda: psser.asof(ps.Index([-100, 100]))
      )
      self.assertRaises(
          ValueError, lambda: psser.asof(ps.Series([-100, 100]))
      )
      self.assertRaises(
          ValueError, lambda: psser.asof(ps.DataFrame({"A": [1, 2, 3]}))
      )
      # asof is not supported for a MultiIndex
      pser.index = pd.MultiIndex.from_tuples(
          [("x", "a"), ("x", "b"), ("y", "c"), ("y", "d")]
      )
      psser = ps.from_pandas(pser)
      self.assertRaises(ValueError, lambda: psser.asof(20))
      # asof requires a sorted index (More precisely, should be a monotonic increasing)
      psser = ps.Series(
          [1, 2, np.nan, 4], index=[10, 30, 20, 40], name="Koalas"
      )
      self.assertRaises(ValueError, lambda: psser.asof(20))
      psser = ps.Series(
          [1, 2, np.nan, 4], index=[40, 30, 20, 10], name="Koalas"
      )
      self.assertRaises(ValueError, lambda: psser.asof(20))
  
      pidx = pd.DatetimeIndex(
          ["2013-12-31", "2014-01-02", "2014-01-03"]
      )
      pser = pd.Series([1, 2, np.nan], index=pidx)
      psser = ps.from_pandas(pser)
  
      self.assert_eq(psser.asof("2014-01-01"), pser.asof("2014-01-01"))
      self.assert_eq(psser.asof("2014-01-02"), pser.asof("2014-01-02"))
      self.assert_eq(
          repr(psser.asof("1999-01-02")), repr(pser.asof("1999-01-02"))
      )
  
      # SPARK-37482: Skip check monotonic increasing for Series.asof with 'compute.eager_check'
      pser = pd.Series([1, 2, np.nan, 4], index=[10, 30, 20, 40])
      psser = ps.from_pandas(pser)
  
      with ps.option_context("compute.eager_check", False):
          self.assert_eq(psser.asof(20), 1.0)
  
      pser = pd.Series([1, 2, np.nan, 4], index=[40, 30, 20, 10])
      psser = ps.from_pandas(pser)
  
      with ps.option_context("compute.eager_check", False):
          self.assert_eq(psser.asof(20), 4.0)
  
      pser = pd.Series(
          [2, 1, np.nan, 4], index=[10, 20, 30, 40], name="Koalas"
      )
      psser = ps.from_pandas(pser)
      self.assert_eq(psser.asof([5, 20]), pser.asof([5, 20]))
  
      pser = pd.Series(
          [4, np.nan, np.nan, 2], index=[10, 20, 30, 40], name="Koalas"
      )
      psser = ps.from_pandas(pser)
      self.assert_eq(psser.asof([5, 100]), pser.asof([5, 100]))
  
      pser = pd.Series(
          [np.nan, 4, 1, 2], index=[10, 20, 30, 40], name="Koalas"
      )
      psser = ps.from_pandas(pser)
      self.assert_eq(psser.asof([5, 35]), pser.asof([5, 35]))
  
      pser = pd.Series(
          [2, 1, np.nan, 4], index=[10, 20, 30, 40], name="Koalas"
      )
      psser = ps.from_pandas(pser)
      self.assert_eq(psser.asof([25, 25]), pser.asof([25, 25]))
  
      pser = pd.Series(
          [2, 1, np.nan, 4], index=["a", "b", "c", "d"], name="Koalas"
      )
      psser = ps.from_pandas(pser)
      self.assert_eq(psser.asof(["a", "d"]), pser.asof(["a", "d"]))
  
      pser = pd.Series(
          [2, 1, np.nan, 4],
          index=[
              pd.Timestamp(2020, 1, 1),
              pd.Timestamp(2020, 2, 2),
              pd.Timestamp(2020, 3, 3),
              pd.Timestamp(2020, 4, 4),
          ],
          name="Koalas",
      )
      psser = ps.from_pandas(pser)
      self.assert_eq(
          psser.asof([pd.Timestamp(2020, 1, 1)]),
          pser.asof([pd.Timestamp(2020, 1, 1)]),
      )
  
      pser = pd.Series(
          [2, np.nan, 1, 4], index=[10, 20, 30, 40], name="Koalas"
      )
      psser = ps.from_pandas(pser)
      self.assert_eq(psser.asof(np.nan), pser.asof(np.nan))
      self.assert_eq(
          psser.asof([np.nan, np.nan]), pser.asof([np.nan, np.nan])
      )
      self.assert_eq(psser.asof([10, np.nan]), pser.asof([10, np.nan]))
  
file_path: spark/python/pyspark/pandas/tests/series/test_as_of.py
imports: import unittest
  import numpy
  import pandas
  from pyspark import pandas
  from pyspark.testing.pandasutils import ComparisonTestBase
  from pyspark.testing.sqlutils import SQLTestUtils
label_desc: Use image node_id 1 for calling the SeriesAsOfMixin obj's underlying member method code with example usage: obj.test_asof() without return types