@@ -5548,7 +5548,7 @@ def _groupby_first_last(
55485548 return result
55495549
55505550 @register_query_compiler_method_not_implemented(
5551- "DataFrameGroupBy",
5551+ [ "DataFrameGroupBy", "SeriesGroupBy"] ,
55525552 "first",
55535553 UnsupportedArgsRule(
55545554 unsupported_conditions=[
@@ -5594,7 +5594,7 @@ def groupby_first(
55945594 )
55955595
55965596 @register_query_compiler_method_not_implemented(
5597- "DataFrameGroupBy",
5597+ [ "DataFrameGroupBy", "SeriesGroupBy"] ,
55985598 "last",
55995599 UnsupportedArgsRule(
56005600 unsupported_conditions=[
@@ -5640,7 +5640,7 @@ def groupby_last(
56405640 )
56415641
56425642 @register_query_compiler_method_not_implemented(
5643- "DataFrameGroupBy",
5643+ [ "DataFrameGroupBy", "SeriesGroupBy"] ,
56445644 "rank",
56455645 UnsupportedArgsRule(
56465646 unsupported_conditions=[
@@ -6102,7 +6102,7 @@ def groupby_rolling(
61026102 return result_qc
61036103
61046104 @register_query_compiler_method_not_implemented(
6105- "DataFrameGroupBy",
6105+ [ "DataFrameGroupBy", "SeriesGroupBy"] ,
61066106 "shift",
61076107 UnsupportedArgsRule(
61086108 unsupported_conditions=[
@@ -7107,7 +7107,7 @@ def groupby_value_counts(
71077107 )
71087108
71097109 @register_query_compiler_method_not_implemented(
7110- "DataFrameGroupBy",
7110+ [ "DataFrameGroupBy", "SeriesGroupBy"] ,
71117111 "fillna",
71127112 UnsupportedArgsRule(
71137113 unsupported_conditions=[
@@ -11875,10 +11875,54 @@ def transpose_single_row(self) -> "SnowflakeQueryCompiler":
1187511875 self._raise_not_implemented_error_for_timedelta()
1187611876
1187711877 frame = self._modin_frame
11878-
11878+ input_column_count = len(frame.data_columns_index)
1187911879 # Handle case where the dataframe has empty columns.
11880- if len(frame.data_columns_index) == 0:
11880+ if input_column_count == 0:
1188111881 return transpose_empty_df(frame)
11882+ if input_column_count == 1:
11883+ # If the frame is 1x1, then the datatype is already preserved; we need only set the entry
11884+ # in the index columns to match the original index labels.
11885+ if len(frame.data_column_index_names) > 1:
11886+ # If the columns object has a multi-index name, we need to project new columns for
11887+ # the extra labels.
11888+ data_odf = frame.ordered_dataframe.select(
11889+ frame.data_column_snowflake_quoted_identifiers
11890+ )
11891+ new_index_column_identifiers = (
11892+ data_odf.generate_snowflake_quoted_identifiers(
11893+ pandas_labels=frame.data_column_pandas_index_names
11894+ )
11895+ )
11896+ new_odf = append_columns(
11897+ data_odf,
11898+ new_index_column_identifiers,
11899+ list(map(pandas_lit, frame.data_column_pandas_labels[0])),
11900+ )
11901+ new_odf.row_count = 1
11902+ return SnowflakeQueryCompiler(
11903+ InternalFrame.create(
11904+ ordered_dataframe=new_odf,
11905+ data_column_pandas_labels=[None],
11906+ data_column_pandas_index_names=[None],
11907+ data_column_snowflake_quoted_identifiers=frame.data_column_snowflake_quoted_identifiers,
11908+ index_column_pandas_labels=frame.data_column_pandas_index_names,
11909+ index_column_snowflake_quoted_identifiers=new_index_column_identifiers,
11910+ data_column_types=frame.cached_data_column_snowpark_pandas_types,
11911+ index_column_types=None,
11912+ )
11913+ )
11914+ else:
11915+ return SnowflakeQueryCompiler(
11916+ frame.update_snowflake_quoted_identifiers_with_expressions(
11917+ {
11918+ frame.index_column_snowflake_quoted_identifiers[
11919+ 0
11920+ ]: pandas_lit(frame.data_column_pandas_labels[0]),
11921+ },
11922+ # Swap the name of the index/columns objects
11923+ new_index_column_pandas_labels=frame.data_column_pandas_index_names,
11924+ )[0]
11925+ ).set_columns([None])
1188211926
1188311927 # This follows the same approach used in SnowflakeQueryCompiler.transpose().
1188411928 # However, as an optimization, only steps (1), (2), and (4) from the four steps described in
@@ -11909,6 +11953,7 @@ def transpose_single_row(self) -> "SnowflakeQueryCompiler":
1190911953 unpivot_result.variable_name_quoted_snowflake_identifier,
1191011954 unpivot_result.object_name_quoted_snowflake_identifier,
1191111955 )
11956+ new_internal_frame.ordered_dataframe.row_count = input_column_count
1191211957
1191311958 return SnowflakeQueryCompiler(new_internal_frame)
1191411959
@@ -11922,8 +11967,9 @@ def transpose(self) -> "SnowflakeQueryCompiler":
1192211967 """
1192311968 frame = self._modin_frame
1192411969
11970+ original_col_count = len(frame.data_columns_index)
1192511971 # Handle case where the dataframe has empty columns.
11926- if len(frame.data_columns_index) == 0:
11972+ if original_col_count == 0:
1192711973 return transpose_empty_df(frame)
1192811974
1192911975 # The following approach to implementing transpose relies on combining unpivot and pivot operations to flip
@@ -12061,6 +12107,7 @@ def transpose(self) -> "SnowflakeQueryCompiler":
1206112107 unpivot_result.variable_name_quoted_snowflake_identifier,
1206212108 unpivot_result.object_name_quoted_snowflake_identifier,
1206312109 )
12110+ new_internal_frame.ordered_dataframe.row_count = original_col_count
1206412111
1206512112 return SnowflakeQueryCompiler(new_internal_frame)
1206612113
0 commit comments