roger-mike commented on a change in pull request #16256:
URL: https://github.com/apache/beam/pull/16256#discussion_r779168377



##########
File path: sdks/python/apache_beam/dataframe/frames_test.py
##########
@@ -1245,6 +1245,39 @@ 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 df_times_shuffled(column, times, df):
+      return df_times(df, column, times)
+
+    def s_times(s, times):
+      return s * times
+
+    def s_times_shuffled(times, s):
+      return s_times(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 = s_times
+    # func_3 = frames.DeferredSeries.append #pd.Series.append
+    func_4 = df_times_shuffled
+    func_5 = s_times_shuffled
+
+    self._run_inplace_test(lambda df: df.pipe(func_1, 'A', 2), df)
+    self._run_inplace_test(lambda df: df.pipe((func_4, 'df'), 'A', 2), df)
+
+    self._run_test(lambda s: s.pipe(func_2, 2), s)
+    self._run_test(lambda s: s.pipe((func_5, 's'), 2), s)
+
+    # self._run_test(lambda s, s2: s.append(s2).pipe(func_2, 2), s, s2)
+    # self._run_test(lambda s, s2: s.pipe(func_3, s2).pipe(func_2, 2), s, s2)

Review comment:
       Not sure if it's the expected behavior but this test doesn't work when 
using either `frames.DeferredSeries.append` or `pd.Series.append` as `func_3`.
   When using the first one it says that only accepts `DeferredSeries` 
instances, and when using the latter it says only accepts `Series` instances. 
Is this test relevant or should it be skippped?




-- 
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]


Reply via email to