You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/01/19 01:30:12 UTC

[GitHub] [spark] dchvn commented on a change in pull request #35240: [SPARK-37930][PYTHON] Fix DataFrame select subset with duplicated columns

dchvn commented on a change in pull request #35240:
URL: https://github.com/apache/spark/pull/35240#discussion_r787280415



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -1143,7 +1143,10 @@ def restore_index(
             drop = index_field not in data_columns
             pdf = pdf.set_index(index_field, drop=drop, append=append)
             append = True
-        pdf = pdf[data_columns]
+
+        # SPARK-37930: Fix DataFrame select subset with duplicated columns
+        # Remove duplicated columns before select `data_columns`
+        pdf = pdf.loc[:, ~pdf.columns.duplicated()][data_columns]

Review comment:
       > can we do `pdf[~pdf.columns.duplicated()][data_columns]`?
   
   I think `pdf[~pdf.columns.duplicated()]` is used to select rows. Do you mind if I keep using `.loc`
   




-- 
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: reviews-unsubscribe@spark.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org