code: def _ts_data_valid(ts_feature, last=False):
      """get the first/last not nan value of pd.Series|DataFrame with single level index"""
      if isinstance(ts_feature, pd.DataFrame):
          return ts_feature.apply(
              lambda column: get_valid_value(column, last=last)
          )
      elif isinstance(ts_feature, pd.Series):
          return get_valid_value(ts_feature, last=last)
      else:
          raise TypeError(
              f"ts_feature should be pd.DataFrame/Series, not {type(ts_feature)}"
          )
  
file_path: qlib/qlib/utils/resam.py
imports: import numpy
  import pandas
  from functools import partial
  from typing import Union, Callable
  from .None import lazy_sort_index
  from .time import Freq, cal_sam_minute
  from ..config import C
label_desc: Use image node_id 5 for calling a global function with example usage: _ts_data_valid(ts_feature, last) and returns: ts_feature, get_valid_value