ueshin commented on a change in pull request #33881:
URL: https://github.com/apache/spark/pull/33881#discussion_r701414469



##########
File path: python/pyspark/pandas/indexing.py
##########
@@ -1370,6 +1365,41 @@ def _select_cols_else(
             cols_sel = (cols_sel,)
         return self._get_from_multiindex_column(cols_sel, missing_keys)
 
+    def _extract_rows_sel_cols_sel(self, key: Any) -> Tuple[Any, Any]:
+        from pyspark.pandas.indexes import MultiIndex
+
+        if isinstance(key, tuple):
+            if len(key) != 2:
+                raise SparkPandasIndexingError("Only accepts pairs of 
candidates")
+            if isinstance(self._psdf.index, MultiIndex) and not 
isinstance(key[0], slice):
+                rows_sel, cols_sel = key, None
+            else:
+                rows_sel, cols_sel = key
+        else:
+            rows_sel = key
+            cols_sel = None
+        return cols_sel, rows_sel
+
+    def _return_psdf_or_psser(
+        self, remaining_index: Optional[int], psdf_or_psser: Union["Series", 
"DataFrame"], key: Any
+    ) -> Optional[Union["Series", "DataFrame"]]:
+        from pyspark.pandas.indexes import MultiIndex
+
+        if remaining_index is not None and remaining_index == 0:
+            pdf_or_pser = psdf_or_psser.head(2).to_pandas()
+            length = len(pdf_or_pser)
+            if length == 0:
+                raise KeyError(name_like_string(key))
+            elif length == 1:
+                if isinstance(self._psdf.index, MultiIndex) and not 
isinstance(key[0], slice):
+                    return pdf_or_pser

Review comment:
       `psdf_or_psser`?




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to