code: def test_to_frame_or_series_apply(setup):
      df1 = DataFrame(
          pd.DataFrame([[0, 1], [2, 3]], columns=["col1", "col2"])
      )
      df2 = df1.append(
          DataFrame(pd.DataFrame(columns=["col1", "col2"]))
      )
      pd_df2 = df2.apply(
          lambda row: pd.Series([1, 2], index=["c", "d"]), axis=1
      ).to_pandas()
      assert pd_df2.columns.tolist() == ["c", "d"]
  
      def f(df):
          df["col3"] = df["col2"]
          return df
  
      pd_df3 = df2.groupby(["col1"]).apply(f).to_pandas()
      assert pd_df3.columns.tolist() == ["col1", "col2", "col3"]
  
      pd_df4 = df2.map_chunk(
          lambda chunk_df: chunk_df.apply(
              lambda row: pd.Series([1, 2], index=["c", "d"]), axis=1
          )
      ).to_pandas()
      assert pd_df4.columns.tolist() == ["c", "d"]
  
      ser1 = Series(
          pd.Series(
              data={"a": 1, "b": 2, "c": 3}, index=["a", "b", "c"]
          )
      )
      ser2 = ser1.append(Series(pd.Series(dtype=np.int64)))
      pd_ser2 = ser2.apply(lambda v: str(v)).execute()
      assert pd_ser2.dtype == object
  
      ser3 = ser2.map_chunk(
          lambda chunk_series: chunk_series.apply(lambda x: float(x))
      ).execute()
  
      def check_dtype(s):
          assert s.dtypes == np.float64
          return s
  
      ser3.map_chunk(check_dtype).execute()
  
file_path: mars/mars/dataframe/tests/test_core.py
imports: import numpy
  import pandas
  import pytest
  from ...core import tile
  from ...lib.groupby_wrapper import wrapped_groupby
  from ...utils import pd_release_version
  from ..None import cut
  from ..initializer import DataFrame, Series, Index
label_desc: Use image node_id 8 for calling a global function with example usage: test_to_frame_or_series_apply(setup) and returns: df, s