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

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

                Author: ASF GitHub Bot
            Created on: 30/Dec/21 19:24
            Start Date: 30/Dec/21 19:24
    Worklog Time Spent: 10m 
      Work Description: roger-mike commented on a change in pull request #16256:
URL: https://github.com/apache/beam/pull/16256#discussion_r776843391



##########
File path: sdks/python/apache_beam/dataframe/frames_test.py
##########
@@ -1245,6 +1245,37 @@ def test_idxmax(self):
     self._run_test(lambda s2: s2.idxmax(), s2)
     self._run_test(lambda s2: s2.idxmax(skipna=False), s2)
 
+  def test_pipe(self):
+    def df_times(df, column, times):
+      df[column] = df[column] * times
+      return df
+
+    def s_times(s, times):
+      return s * times
+
+    df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}, index=[0, 1, 2])
+    s = pd.Series([1, 2, 3, 4, 5], index=[0, 1, 2, 3, 4])
+    # s2 = pd.Series([6, 7], index=[5, 6])
+
+    func_1 = df_times
+    func_2 = frames.DeferredDataFrame.sum
+    func_3 = frames.DeferredSeries.sum
+    func_4 = s_times
+    # func_5 = frames.DeferredSeries.append
+
+    self._run_inplace_test(lambda df: df.pipe(func_1, 'A', 2), df)
+    self._run_test(lambda df: df.pipe(func_2), df)
+    # type assert fails when axis=1
+    # self._run_test(lambda df: df.pipe(func_2, axis=1), df)
+    self._run_inplace_test(lambda df: df.pipe(func_1, 'A', 2).pipe(func_2), df)
+    self._run_test(lambda df: df.pipe(func_2).pipe(func_3), df)
+
+    self._run_test(lambda s: s.pipe(func_4, 2), s)
+    self._run_test(lambda s: s.pipe(func_3), s)
+    self._run_test(lambda s: s.pipe(func_4, 2).pipe(func_3), s)
+    # Can't append non-deferred series
+    # self._run_test(lambda s: s.pipe(func_5, s2).pipe(func_4, 2), s)

Review comment:
       Does `s2` need to be wrapped as a DeferredSeries to make it work?




-- 
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: 702403)
    Time Spent: 3h 20m  (was: 3h 10m)

> Implement pipe for DataFrame, Series, and GroupBy
> -------------------------------------------------
>
>                 Key: BEAM-12562
>                 URL: https://issues.apache.org/jira/browse/BEAM-12562
>             Project: Beam
>          Issue Type: Improvement
>          Components: dsl-dataframe
>            Reporter: Brian Hulette
>            Assignee: Mike Hernandez
>            Priority: P3
>          Time Spent: 3h 20m
>  Remaining Estimate: 0h
>
> Add an implementation of 
> [pipe|https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.pipe.html]
>  for DeferredDataFrame, DeferredSeries, and DeferredGroupBy. It should be 
> fully unit tested with some combination of pandas_doctests_test.py and 
> frames_test.py.
> https://github.com/apache/beam/pull/14274 is an example of a typical PR that 
> adds new operations. See 
> https://lists.apache.org/thread.html/r8ffe96d756054610dfdb4e849ffc6a741e826d15ba7e5bdeee1b4266%40%3Cdev.beam.apache.org%3E
>  for background on the DataFrame API.



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

Reply via email to