code: def kpss_stationarity(
      data: pd.Series, confidence_level: float = 0.05
  ) -> TestResult:
      """Kwiatkowski-Phillips-Schmidt-Shin test for the null hypothesis that the data is level or
      trend stationary.
  
      Args:
          data (pd.Series): Time series.
          confidence_level (float): Confidence level for rejecting the null hypothesis.
  
      Returns:
          TestResult: test name, p-value, null hypothesis, reject?, confidence level and details.
  
      See Also:
          https://www.statsmodels.org/stable/generated/statsmodels.tsa.stattools.kpss.html
      """
      ser_clean = data
      if np.isnan(data).any():
          ser_clean = data.dropna()
          warnings.warn("Found and removed N/A values.", UserWarning)
  
      try:
          test_statistic, p_value, n_lags, crit, *_ = kpss(
              ser_clean, nlags="auto"
          )
      except (ValueError, OverflowError) as e:
          test_statistic, p_value, n_lags, crit = (
              np.nan,
              np.nan,
              None,
              None,
          )
          warnings.warn(str(e), UserWarning)
  
      outcome_specifics = {
          "test_statistic": test_statistic,
          "n_lags": n_lags,
          "critical_values": crit,
      }
      reject_h0 = bool(p_value < confidence_level)
      result = TestResult(
          test="Kwiatkowski-Phillips-Schmidt-Shin",
          p_value=float(p_value),
          confidence_level=confidence_level,
          null_hypothesis="Data is level stationary",
          reject_null_hypothesis=reject_h0,
          details=outcome_specifics,
      )
  
      return result
  
file_path: tslumen/tslumen/profile/stat_tests.py
imports: from typing import Dict, Any, Optional
  from dataclasses import dataclass
  import math
  import warnings
  import numpy
  import pandas
  import scipy
  import statsmodels.stats.api
  from statsmodels.tsa.tsatools import freq_to_period
  from statsmodels.tsa.stattools import acf, adfuller, kpss
  from tslumen.profile.base import ProfilingFunction, _DCDict
  from tslumen.misc import repr_html
label_desc: Use image node_id 6 for calling a global function with example usage: kpss_stationarity(data, confidence_level) and returns: result