robertwb commented on a change in pull request #12858:
URL: https://github.com/apache/beam/pull/12858#discussion_r490028277



##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -763,8 +788,9 @@ def sort_values(self, axis, **kwargs):
   transform = frame_base._elementwise_method(
       'transform', restrictions={'axis': 0})
 
-  def transpose(self, *args, **kwargs):
-    raise frame_base.WontImplementError('non-deferred column values')
+  transpose = frame_base.wont_implement_method('non-deferred column values')
+  pivot = frame_base.wont_implement_method('non-deferred column values')

Review comment:
       I've been thinking we could do something here if the value type that 
goes into the columns are categorical. 

##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -279,13 +267,23 @@ def __getattr__(self, name):
 
   def __getitem__(self, key):
     # TODO: Replicate pd.DataFrame.__getitem__ logic
-    if (isinstance(key, list) and
-        all(key_column in self._expr.proxy().columns
-            for key_column in key)) or key in self._expr.proxy().columns:
+    if isinstance(key, frame_base.DeferredBase):
+      # Fail early if key is a DeferredBase as it interacts surprisingly with
+      # key in self._expr.proxy().columns
+      raise NotImplementedError(
+          "Indexing with a deferred frame is not yet supported. Consider "
+          "using df.loc[...]")
+
+    if (isinstance(key, list) and key_column in self._expr.proxy().columns

Review comment:
       The all was dropped here, which makes the statement always true.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to