text: Title: BUG: SeriesGroupBy.apply applies function to pandas DataFrame instead of to pandas Series
  Body: ### Modin version checks
  
  - [X] I have checked that this issue has not already been reported.
  
  - [X] I have confirmed this bug exists on the latest released version of Modin.
  
  - [X] I have confirmed this bug exists on the main branch of Modin. (In order to do this you can follow [this guide](https://modin.readthedocs.io/en/stable/getting_started/installation.html#installing-from-the-github-master-branch).)
  
  
  ### Reproducible Example
  
  ```python
  import modin.pandas as pd
  
  df = pd.DataFrame(['a', 'b'])
  df[0].groupby(df[0]).apply(lambda x: x.to_frame())
  ```
  
  
  ### Issue Description
  
  in `SeriesGroupBy`, `func` always operates on a series, and never on a dataframe.  We need to pass a signal [here](https://github.com/modin-project/modin/blob/cbb3b5da2cff8db2ff41715f1e98ae61d632eba1/modin/pandas/groupby.py#L1863) that `func` applies to series, not to frames.
  
  code example works in pandas:
  
  ```python
  import pandas as pd 
  
  df = pd.DataFrame(['a', 'b'])
  df[0].groupby(df[0]).apply(lambda x: x.to_frame())
  ```
  
  ### Expected Behavior
  
  should match pandas
  
  ### Error Logs
  
  <details>
  
  ```python-traceback
  
  ---------------------------------------------------------------------------
  RayTaskError(AttributeError)              Traceback (most recent call last)
  Cell In[1], line 4
        1 import modin.pandas as pd
        3 df = pd.DataFrame(['a', 'b'])
  ----> 4 df[0].groupby(df[0]).apply(lambda x: x.to_frame())
  
  File ~/sources/modin/modin/logging/logger_decorator.py:125, in enable_logging.<locals>.decorator.<locals>.run_and_log(*args, **kwargs)
      110 """
      111 Compute function with logging if Modin logging is enabled.
      112
     (...)
      122 Any
      123 """
      124 if LogMode.get() == "disable":
  --> 125     return obj(*args, **kwargs)
      127 logger = get_logger()
      128 logger.log(log_level, start_line)
  
  File ~/sources/modin/modin/pandas/groupby.py:1863, in SeriesGroupBy.apply(self, func, *args, **kwargs)
     1862 def apply(self, func, *args, **kwargs):
  -> 1863     return super().apply(func, *args, **kwargs)
  
  File ~/sources/modin/modin/logging/logger_decorator.py:125, in enable_logging.<locals>.decorator.<locals>.run_and_log(*args, **kwargs)
      110 """
      111 Compute function with logging if Modin logging is enabled.
      112
     (...)
      122 Any
      123 """
      124 if LogMode.get() == "disable":
  --> 125     return obj(*args, **kwargs)
      127 logger = get_logger()
      128 logger.log(log_level, start_line)
  
  File ~/sources/modin/modin/pandas/groupby.py:654, in DataFrameGroupBy.apply(self, func, include_groups, *args, **kwargs)
      651 if not isinstance(func, BuiltinFunctionType):
      652     func = wrap_udf_function(func)
  --> 654 apply_res = self._wrap_aggregation(
      655     qc_method=type(self._query_compiler).groupby_agg,
      656     numeric_only=False,
      657     agg_func=func,
      658     agg_args=args,
      659     agg_kwargs={**kwargs, "include_groups": include_groups},
      660     how="group_wise",
      661 )
      662 reduced_index = pandas.Index([MODIN_UNNAMED_SERIES_LABEL])
      663 if not isinstance(apply_res, Series) and apply_res.columns.equals(
      664     reduced_index
      665 ):
  
  File ~/sources/modin/modin/logging/logger_decorator.py:125, in enable_logging.<locals>.decorator.<locals>.run_and_log(*args, **kwargs)
      110 """
      111 Compute function with logging if Modin logging is enabled.
      112
     (...)
      122 Any
      123 """
      124 if LogMode.get() == "disable":
  --> 125     return obj(*args, **kwargs)
      127 logger = get_logger()
      128 logger.log(log_level, start_line)
  
  File ~/sources/modin/modin/pandas/groupby.py:1664, in DataFrameGroupBy._wrap_aggregation(self, qc_method, numeric_only, agg_args, agg_kwargs, **kwargs)
     1661 else:
     1662     groupby_qc = self._query_compiler
  -> 1664 return type(self._df)(
     1665     query_compiler=qc_method(
     1666         groupby_qc,
     1667         by=self._by,
     1668         axis=self._axis,
     1669         groupby_kwargs=self._kwargs,
     1670         agg_args=agg_args,
     1671         agg_kwargs=agg_kwargs,
     1672         drop=self._drop,
     1673         **kwargs,
     1674     )
     1675 )
  
  File ~/sources/modin/modin/logging/logger_decorator.py:125, in enable_logging.<locals>.decorator.<locals>.run_and_log(*args, **kwargs)
      110 """
      111 Compute function with logging if Modin logging is enabled.
      112
     (...)
      122 Any
      123 """
      124 if LogMode.get() == "disable":
  --> 125     return obj(*args, **kwargs)
      127 logger = get_logger()
      128 logger.log(log_level, start_line)
  
  File ~/sources/modin/modin/pandas/series.py:151, in Series.__init__(self, data, index, dtype, name, copy, fastpath, query_compiler)
      137             name = data.name
      139     query_compiler = from_pandas(
      140         pandas.DataFrame(
      141             pandas.Series(
     (...)
      149         )
      150     )._query_compiler
  --> 151 self._query_compiler = query_compiler.columnarize()
      152 if name is not None:
      153     self.name = name
  
  File ~/sources/modin/modin/logging/logger_decorator.py:125, in enable_logging.<locals>.decorator.<locals>.run_and_log(*args, **kwargs)
      110 """
      111 Compute function with logging if Modin logging is enabled.
      112
     (...)
      122 Any
      123 """
      124 if LogMode.get() == "disable":
  --> 125     return obj(*args, **kwargs)
      127 logger = get_logger()
      128 logger.log(log_level, start_line)
  
  File ~/sources/modin/modin/core/storage_formats/base/query_compiler.py:1258, in BaseQueryCompiler.columnarize(self)
     1255     return self
     1257 result = self
  -> 1258 if len(self.columns) != 1 or (
     1259     len(self.index) == 1 and self.index[0] == MODIN_UNNAMED_SERIES_LABEL
     1260 ):
     1261     result = self.transpose()
     1262 result._shape_hint = "column"
  
  File ~/sources/modin/modin/core/storage_formats/pandas/query_compiler.py:99, in _get_axis.<locals>.<lambda>(self)
       97     return lambda self: self._modin_frame.index
       98 else:
  ---> 99     return lambda self: self._modin_frame.columns
  
  File ~/sources/modin/modin/core/dataframe/pandas/dataframe/dataframe.py:691, in PandasDataframe._get_columns(self)
      682 """
      683 Get the columns from the cache object.
      684
     (...)
      688     An index object containing the column labels.
      689 """
      690 if self.has_columns_cache:
  --> 691     columns, column_widths = self._columns_cache.get(return_lengths=True)
      692 else:
      693     columns, column_widths = self._compute_axis_labels_and_lengths(1)
  
  File ~/sources/modin/modin/core/dataframe/pandas/metadata/index.py:202, in ModinIndex.get(self, return_lengths)
      200 if not self.is_materialized:
      201     if callable(self._value):
  --> 202         index, self._lengths_cache = self._value()
      203         self._value = ensure_index(index)
      204     elif self._value is None:
  
  File ~/sources/modin/modin/logging/logger_decorator.py:125, in enable_logging.<locals>.decorator.<locals>.run_and_log(*args, **kwargs)
      110 """
      111 Compute function with logging if Modin logging is enabled.
      112
     (...)
      122 Any
      123 """
      124 if LogMode.get() == "disable":
  --> 125     return obj(*args, **kwargs)
      127 logger = get_logger()
      128 logger.log(log_level, start_line)
  
  File ~/sources/modin/modin/core/dataframe/pandas/dataframe/dataframe.py:799, in PandasDataframe._compute_axis_labels_and_lengths(self, axis, partitions)
      797 if partitions is None:
      798     partitions = self._partitions
  --> 799 new_index, internal_idx = self._partition_mgr_cls.get_indices(axis, partitions)
      800 return new_index, list(map(len, internal_idx))
  
  File ~/sources/modin/modin/logging/logger_decorator.py:125, in enable_logging.<locals>.decorator.<locals>.run_and_log(*args, **kwargs)
      110 """
      111 Compute function with logging if Modin logging is enabled.
      112
     (...)
      122 Any
      123 """
      124 if LogMode.get() == "disable":
  --> 125     return obj(*args, **kwargs)
      127 logger = get_logger()
      128 logger.log(log_level, start_line)
  
  File ~/sources/modin/modin/core/dataframe/pandas/partitioning/partition_manager.py:1045, in PandasDataframePartitionManager.get_indices(cls, axis, partitions, index_func)
     1043 if len(target):
     1044     new_idx = [idx.apply(func) for idx in target[0]]
  -> 1045     new_idx = cls.get_objects_from_partitions(new_idx)
     1046 else:
     1047     new_idx = [pandas.Index([])]
  
  File ~/sources/modin/modin/logging/logger_decorator.py:125, in enable_logging.<locals>.decorator.<locals>.run_and_log(*args, **kwargs)
      110 """
      111 Compute function with logging if Modin logging is enabled.
      112
     (...)
      122 Any
      123 """
      124 if LogMode.get() == "disable":
  --> 125     return obj(*args, **kwargs)
      127 logger = get_logger()
      128 logger.log(log_level, start_line)
  
  File ~/sources/modin/modin/core/dataframe/pandas/partitioning/partition_manager.py:986, in PandasDataframePartitionManager.get_objects_from_partitions(cls, partitions)
      982             partitions[idx] = part.force_materialization()
      983     assert all(
      984         [len(partition.list_of_blocks) == 1 for partition in partitions]
      985     ), "Implementation assumes that each partition contains a single block."
  --> 986     return cls._execution_wrapper.materialize(
      987         [partition.list_of_blocks[0] for partition in partitions]
      988     )
      989 return [partition.get() for partition in partitions]
  
  File ~/sources/modin/modin/core/execution/ray/common/engine_wrapper.py:129, in RayWrapper.materialize(cls, obj_id)
      126     return ray.get(obj_id) if isinstance(obj_id, RayObjectRefTypes) else obj_id
      128 if all(isinstance(obj, RayObjectRefTypes) for obj in obj_id):
  --> 129     return ray.get(obj_id)
      131 ids = {}
      132 result = []
  
  File ~/miniconda3/envs/modin-latest/lib/python3.9/site-packages/ray/_private/auto_init_hook.py:24, in wrap_auto_init.<locals>.auto_init_wrapper(*args, **kwargs)
       21 @wraps(fn)
       22 def auto_init_wrapper(*args, **kwargs):
       23     auto_init_ray()
  ---> 24     return fn(*args, **kwargs)
  
  File ~/miniconda3/envs/modin-latest/lib/python3.9/site-packages/ray/_private/client_mode_hook.py:103, in client_mode_hook.<locals>.wrapper(*args, **kwargs)
      101     if func.__name__ != "init" or is_client_mode_enabled_by_default:
      102         return getattr(ray, func.__name__)(*args, **kwargs)
  --> 103 return func(*args, **kwargs)
  
  File ~/miniconda3/envs/modin-latest/lib/python3.9/site-packages/ray/_private/worker.py:2563, in get(object_refs, timeout)
     2561     worker.core_worker.dump_object_store_memory_usage()
     2562 if isinstance(value, RayTaskError):
  -> 2563     raise value.as_instanceof_cause()
     2564 else:
     2565     raise value
  
  RayTaskError(AttributeError): ray::remote_exec_func() (pid=65613, ip=127.0.0.1)
    At least one of the input arguments for this task could not be computed:
  ray.exceptions.RayTaskError: ray::_deploy_ray_func() (pid=65613, ip=127.0.0.1)
    File "/Users/mvashishtha/sources/modin/modin/core/execution/ray/implementations/pandas_on_ray/partitioning/virtual_partition.py", line 324, in _deploy_ray_func
      result = deployer(axis, f_to_deploy, f_args, f_kwargs, *deploy_args, **kwargs)
    File "/Users/mvashishtha/sources/modin/modin/logging/logger_decorator.py", line 125, in run_and_log
      return obj(*args, **kwargs)
    File "/Users/mvashishtha/sources/modin/modin/core/dataframe/pandas/partitioning/axis_partition.py", line 433, in deploy_axis_func
      result = func(dataframe, *f_args, **f_kwargs)
    File "/Users/mvashishtha/sources/modin/modin/core/dataframe/pandas/dataframe/dataframe.py", line 1989, in _tree_reduce_func
      series_result = func(df, *args, **kwargs)
    File "/Users/mvashishtha/sources/modin/modin/core/dataframe/pandas/dataframe/dataframe.py", line 4077, in apply_func
      result = operator(df.groupby(by, **kwargs))
    File "/Users/mvashishtha/sources/modin/modin/core/storage_formats/pandas/query_compiler.py", line 3752, in <lambda>
      operator=lambda grp: agg_func(grp, *agg_args, **agg_kwargs),
    File "/Users/mvashishtha/sources/modin/modin/core/storage_formats/pandas/query_compiler.py", line 3733, in agg_func
      result = agg_method(grp, original_agg_func, *args, **kwargs)
    File "/Users/mvashishtha/miniconda3/envs/modin-latest/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 1824, in apply
      result = self._python_apply_general(f, self._selected_obj)
    File "/Users/mvashishtha/miniconda3/envs/modin-latest/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 1885, in _python_apply_general
      values, mutated = self._grouper.apply_groupwise(f, data, self.axis)
    File "/Users/mvashishtha/miniconda3/envs/modin-latest/lib/python3.9/site-packages/pandas/core/groupby/ops.py", line 919, in apply_groupwise
      res = f(group)
    File "/Users/mvashishtha/sources/modin/modin/utils.py", line 689, in wrapper
      result = func(*args, **kwargs)
    File "<ipython-input-1-cf24b11d0b7f>", line 4, in <lambda>
    File "/Users/mvashishtha/miniconda3/envs/modin-latest/lib/python3.9/site-packages/pandas/core/generic.py", line 6296, in __getattr__
      return object.__getattribute__(self, name)
  AttributeError: 'DataFrame' object has no attribute 'to_frame'
  
  ```
  
  </details>
  
  
  ### Installed Versions
  
  <details>
  
  INSTALLED VERSIONS
  ------------------
  commit                : c75343687799e3b69fc04a99b8a9d11eab1fd984
  python                : 3.9.18.final.0
  python-bits           : 64
  OS                    : Darwin
  OS-release            : 23.4.0
  Version               : Darwin Kernel Version 23.4.0: Wed Feb 21 21:45:49 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T6020
  machine               : arm64
  processor             : arm
  byteorder             : little
  LC_ALL                : None
  LANG                  : en_US.UTF-8
  LOCALE                : en_US.UTF-8
  
  Modin dependencies
  ------------------
  modin                 : 0.28.0+23.gc7534368
  ray                   : 2.8.0
  dask                  : None
  distributed           : None
  hdk                   : None
  
  pandas dependencies
  -------------------
  pandas                : 2.2.1
  numpy                 : 1.26.1
  pytz                  : 2023.3.post1
  dateutil              : 2.8.2
  setuptools            : 68.0.0
  pip                   : 23.3
  Cython                : None
  pytest                : None
  hypothesis            : None
  sphinx                : None
  blosc                 : None
  feather               : None
  xlsxwriter            : None
  lxml.etree            : None
  html5lib              : None
  pymysql               : None
  psycopg2              : None
  jinja2                : 3.1.2
  IPython               : 8.17.2
  pandas_datareader     : None
  adbc-driver-postgresql: None
  adbc-driver-sqlite    : None
  bs4                   : None
  bottleneck            : None
  dataframe-api-compat  : None
  fastparquet           : None
  fsspec                : 2023.10.0
  gcsfs                 : None
  matplotlib            : 3.8.1
  numba                 : None
  numexpr               : None
  odfpy                 : None
  openpyxl              : None
  pandas_gbq            : None
  pyarrow               : 14.0.1
  pyreadstat            : None
  python-calamine       : None
  pyxlsb                : None
  s3fs                  : None
  scipy                 : 1.11.3
  sqlalchemy            : None
  tables                : None
  tabulate              : None
  xarray                : None
  xlrd                  : None
  zstandard             : None
  tzdata                : 2023.3
  qtpy                  : None
  pyqt5                 : None
  
  </details>
  