You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2021/06/24 17:28:06 UTC

[GitHub] [beam] rohdesamuel commented on a change in pull request #15072: [BEAM-12533] Define a `__repr__` for `DeferredDataFrame` and `DeferredSeries`

rohdesamuel commented on a change in pull request #15072:
URL: https://github.com/apache/beam/pull/15072#discussion_r658145465



##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -1843,9 +1873,69 @@ def repeat(self, repeats, axis):
           f"DeferredSeries (encountered {type(repeats)}).")
 
 
+def _justify_str_column(objs, rjust=True):
+  strs = [str(o) for o in objs]
+  maxlen = max(len(s) for s in strs)
+  return [s.rjust(maxlen) if rjust else s.ljust(maxlen) for s in strs]
+
+
+def _ljustify_str_column(objs):
+  strs = [str(o) for o in objs]
+  maxlen = max(len(s) for s in strs)
+  return [s.ljust(maxlen) for s in strs]
+
+
+def _justify_columns_and_transpose(columns, rjust=True):
+  for row in zip(*[_justify_str_column(objs, rjust) for objs in columns]):
+    yield ' '.join(row)
+
+
 @populate_not_implemented(pd.DataFrame)
 @frame_base.DeferredFrame._register_for(pd.DataFrame)
 class DeferredDataFrame(DeferredDataFrameOrSeries):

Review comment:
       Given that DataFrames are just concatenated Series, could this be simplified to concat the `__repr__` on the underlying Series?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org