nodes: 0, module; 1, function_definition; 2, function_name:asof; 3, parameters; 4, block; 5, identifier:self; 6, identifier:label; 7, expression_statement; 8, try_statement; 9, comment:"""
          Return the label from the index, or, if not present, the previous one.
  
          Assuming that the index is sorted, return the passed index label if it
          is in the index, or return the previous index label if the passed one
          is not in the index.
  
          Parameters
          ----------
          label : object
              The label up to which the method returns the latest index label.
  
          Returns
          -------
          object
              The passed label if it is in the index. The previous label if the
              passed label is not in the sorted index or `NaN` if there is no
              such label.
  
          See Also
          --------
          Series.asof : Return the latest value in a Series up to the
              passed index.
          merge_asof : Perform an asof merge (similar to left join but it
              matches on nearest key rather than equal key).
          Index.get_loc : An `asof` is a thin wrapper around `get_loc`
              with method='pad'.
  
          Examples
          --------
          `Index.asof` returns the latest index label up to the passed label.
  
          >>> idx = pd.Index(['2013-12-31', '2014-01-02', '2014-01-03'])
          >>> idx.asof('2014-01-01')
          '2013-12-31'
  
          If the label is in the index, the method returns the passed label.
  
          >>> idx.asof('2014-01-02')
          '2014-01-02'
  
          If all of the labels in the index are later than the passed label,
          NaN is returned.
  
          >>> idx.asof('1999-01-02')
          nan
  
          If the index is not sorted, an error is raised.
  
          >>> idx_not_sorted = pd.Index(['2013-12-31', '2015-01-02',
          ...                            '2014-01-03'])
          >>> idx_not_sorted.asof('2013-12-31')
          Traceback (most recent call last):
          ValueError: index must be monotonic increasing or decreasing
          """; 10, block; 11, except_clause; 12, else_clause; 13, expression_statement; 14, identifier:KeyError; 15, block; 16, block; 17, assignment; 18, return_statement; 19, if_statement; 20, return_statement; 21, identifier:loc; 22, call; 23, attribute; 24, call; 25, block; 26, subscript; 27, attribute; 28, argument_list; 29, identifier:self; 30, identifier:_na_value; 31, identifier:isinstance; 32, argument_list; 33, expression_statement; 34, identifier:self; 35, identifier:loc; 36, identifier:self; 37, identifier:get_loc; 38, identifier:label; 39, keyword_argument; 40, identifier:loc; 41, identifier:slice; 42, assignment; 43, identifier:method; 44, string; 45, identifier:loc; 46, subscript; 47, string_content:pad; 48, call; 49, unary_operator; 50, attribute; 51, argument_list; 52, integer:1; 53, identifier:loc; 54, identifier:indices; 55, call; 56, identifier:len; 57, argument_list; 58, identifier:self
code: def asof(self, label):
          """
          Return the label from the index, or, if not present, the previous one.
  
          Assuming that the index is sorted, return the passed index label if it
          is in the index, or return the previous index label if the passed one
          is not in the index.
  
          Parameters
          ----------
          label : object
              The label up to which the method returns the latest index label.
  
          Returns
          -------
          object
              The passed label if it is in the index. The previous label if the
              passed label is not in the sorted index or `NaN` if there is no
              such label.
  
          See Also
          --------
          Series.asof : Return the latest value in a Series up to the
              passed index.
          merge_asof : Perform an asof merge (similar to left join but it
              matches on nearest key rather than equal key).
          Index.get_loc : An `asof` is a thin wrapper around `get_loc`
              with method='pad'.
  
          Examples
          --------
          `Index.asof` returns the latest index label up to the passed label.
  
          >>> idx = pd.Index(['2013-12-31', '2014-01-02', '2014-01-03'])
          >>> idx.asof('2014-01-01')
          '2013-12-31'
  
          If the label is in the index, the method returns the passed label.
  
          >>> idx.asof('2014-01-02')
          '2014-01-02'
  
          If all of the labels in the index are later than the passed label,
          NaN is returned.
  
          >>> idx.asof('1999-01-02')
          nan
  
          If the index is not sorted, an error is raised.
  
          >>> idx_not_sorted = pd.Index(['2013-12-31', '2015-01-02',
          ...                            '2014-01-03'])
          >>> idx_not_sorted.asof('2013-12-31')
          Traceback (most recent call last):
          ValueError: index must be monotonic increasing or decreasing
          """
          try:
              loc = self.get_loc(label, method='pad')
          except KeyError:
              return self._na_value
          else:
              if isinstance(loc, slice):
                  loc = loc.indices(len(self))[-1]
              return self[loc]