code: def test_replace_execution(setup):
      # dataframe cases
      df_raw = pd.DataFrame(
          -1, index=range(0, 20), columns=list("ABCDEFGHIJ")
      )
      for _ in range(30):
          df_raw.iloc[
              random.randint(0, 19), random.randint(0, 9)
          ] = random.randint(0, 99)
      for rowid in range(random.randint(1, 5)):
          row = random.randint(0, 19)
          for idx in range(0, 10):
              df_raw.iloc[row, idx] = random.randint(0, 99)
      df = md.DataFrame(df_raw, chunk_size=4)
  
      r = df.replace(-1, method="ffill")
      pd.testing.assert_frame_equal(
          r.execute().fetch(), df_raw.replace(-1, method="ffill")
      )
  
      r = df.replace(-1, method="bfill")
      pd.testing.assert_frame_equal(
          r.execute().fetch(), df_raw.replace(-1, method="bfill")
      )
  
      r = df.replace(-1, 999)
      pd.testing.assert_frame_equal(
          r.execute().fetch(), df_raw.replace(-1, 999)
      )
  
      if pd.__version__ >= "1.4.4":
          r = df.replace({-1: 999})
          pd.testing.assert_frame_equal(
              r.execute().fetch(), df_raw.replace({-1: 999})
          )
  
      raw_to_replace = pd.Series([-1, 1, 2])
      to_replace_series = md.Series(raw_to_replace)
      raw_value = pd.Series([2, 3, -1])
      value_series = md.Series(raw_value)
      r = df.replace(to_replace_series, value_series)
      pd.testing.assert_frame_equal(
          r.execute().fetch(), df_raw.replace(raw_to_replace, raw_value)
      )
  
      df.replace({"A": -1}, {"A": 9}, inplace=True)
      pd.testing.assert_frame_equal(
          df.execute().fetch(), df_raw.replace({"A": -1}, {"A": 9})
      )
  
      if pd.__version__ >= "1.4.4":
          df.replace({"A": {-1: 9}}, inplace=True)
          pd.testing.assert_frame_equal(
              df.execute().fetch(), df_raw.replace({"A": {-1: 9}})
          )
  
      # series cases
      series_raw = pd.Series(-1, index=range(20))
      for _ in range(10):
          series_raw.iloc[random.randint(0, 19)] = random.randint(0, 99)
      series = md.Series(series_raw, chunk_size=4)
  
      if pd.__version__ >= "1.4.4":
          r = series.replace(-1)
          pd.testing.assert_series_equal(
              r.execute().fetch(), series_raw.replace(-1)
          )
  
      r = series.replace(-1, method="ffill")
      pd.testing.assert_series_equal(
          r.execute().fetch(), series_raw.replace(-1, method="ffill")
      )
  
      r = series.replace(-1, method="bfill")
      pd.testing.assert_series_equal(
          r.execute().fetch(), series_raw.replace(-1, method="bfill")
      )
  
      r = series.replace(-1, 999)
      pd.testing.assert_series_equal(
          r.execute().fetch(), series_raw.replace(-1, 999)
      )
  
      # str series cases
      tmpl_chars = list(string.ascii_letters + string.digits)
      random.shuffle(tmpl_chars)
  
      def _rand_slice():
          lb = random.randint(0, len(tmpl_chars) - 1)
          rb = random.randint(lb, len(tmpl_chars) - 1)
          return "".join(tmpl_chars[lb : rb + 1])
  
      series_raw = pd.Series([_rand_slice() for _ in range(20)])
      series = md.Series(series_raw, chunk_size=4)
  
      regs = [
          re.compile(r".A.", flags=re.IGNORECASE),
          re.compile(r".B.", flags=re.IGNORECASE),
          re.compile(r".C.", flags=re.IGNORECASE),
          re.compile(r".D.", flags=re.IGNORECASE),
      ]
      r = series.replace(regex=regs, value="new")
      pd.testing.assert_series_equal(
          r.execute().fetch(),
          series_raw.replace(regex=regs, value="new"),
      )
  
file_path: mars/mars/dataframe/missing/tests/test_missing_execution.py
imports: import random
  import re
  import string
  import numpy
  import pandas
  from ....None import dataframe
label_desc: Use image node_id 6 for calling a global function with example usage: test_replace_execution(setup) and returns: str