[ 
https://issues.apache.org/jira/browse/BEAM-13966?focusedWorklogId=745036&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-745036
 ]

ASF GitHub Bot logged work on BEAM-13966:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Mar/22 13:07
            Start Date: 21/Mar/22 13:07
    Worklog Time Spent: 10m 
      Work Description: yeandy commented on a change in pull request #17043:
URL: https://github.com/apache/beam/pull/17043#discussion_r831083933



##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -3655,6 +3655,40 @@ def shift(self, axis, freq, **kwargs):
   describe = _agg_method(pd.DataFrame, 'describe')
   max = _agg_method(pd.DataFrame, 'max')
   min = _agg_method(pd.DataFrame, 'min')
+
+  @frame_base.with_docs_from(pd.DataFrame)
+  @frame_base.args_to_kwargs(pd.DataFrame)
+  @frame_base.populate_defaults(pd.DataFrame)
+  def pivot(self, **kwargs):
+    columns = kwargs.get('columns', None)
+    selected_cols = self._expr.proxy()[columns]
+
+    if isinstance(selected_cols, pd.Series):
+      all_cols_are_categorical = isinstance(
+        selected_cols.dtype, pd.CategoricalDtype
+      )
+    else:
+      all_cols_are_categorical = all(
+        isinstance(c, pd.CategoricalDtype) for c in selected_cols.dtypes
+      )
+    if not all_cols_are_categorical:
+      raise frame_base.WontImplementError(
+          "pivot() of non-categorical type is not supported because "
+          "the type of the output column depends on the data. Please use "
+          "pd.CategoricalDtype with explicit categories.",
+          reason="non-deferred-columns")
+
+    proxy = pd.DataFrame(columns=self._expr.proxy().pivot(**kwargs).columns)
+
+    with expressions.allow_non_parallel_operations():

Review comment:
       Changed!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 745036)
    Time Spent: 1h 20m  (was: 1h 10m)

> Implement DataFrame.pivot() for DataFrame API
> ---------------------------------------------
>
>                 Key: BEAM-13966
>                 URL: https://issues.apache.org/jira/browse/BEAM-13966
>             Project: Beam
>          Issue Type: Sub-task
>          Components: dsl-dataframe, sdk-py-core
>            Reporter: Andy Ye
>            Assignee: Andy Ye
>            Priority: P3
>              Labels: dataframe-api
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to