HyukjinKwon commented on a change in pull request #34179:
URL: https://github.com/apache/spark/pull/34179#discussion_r723793429
##########
File path: python/pyspark/pandas/tests/test_dataframe.py
##########
@@ -6000,6 +6000,20 @@ def test_combine_first(self):
expected_pdf = pd.DataFrame({"A": [None, 0], "B": [4.0, 1.0], "C":
[3, 3]})
self.assert_eq(expected_pdf, psdf1.combine_first(psdf2))
+ def test_multi_index_dtypes(self):
+ # SPARK-36930: Support ps.MultiIndex.dtypes
+ arrays = [[1, 1, 2, 2], ["red", "blue", "red", "blue"]]
+ pmidx = pd.MultiIndex.from_arrays(arrays, names=("number", "color"))
+ psmidx = ps.from_pandas(pmidx)
+
+ self.assert_eq(psmidx.dtypes, pmidx.dtypes)
Review comment:
@dchvn, `dtypes` in `MultiIndex` only exists in pandas 1.3+ so the tests
won't be able to run with lower pandas versions. Can you make a followup PR to
skip conditionally this test when pandas version is lower?
##########
File path: python/pyspark/pandas/tests/test_dataframe.py
##########
@@ -6000,6 +6000,20 @@ def test_combine_first(self):
expected_pdf = pd.DataFrame({"A": [None, 0], "B": [4.0, 1.0], "C":
[3, 3]})
self.assert_eq(expected_pdf, psdf1.combine_first(psdf2))
+ def test_multi_index_dtypes(self):
+ # SPARK-36930: Support ps.MultiIndex.dtypes
+ arrays = [[1, 1, 2, 2], ["red", "blue", "red", "blue"]]
+ pmidx = pd.MultiIndex.from_arrays(arrays, names=("number", "color"))
+ psmidx = ps.from_pandas(pmidx)
+
+ self.assert_eq(psmidx.dtypes, pmidx.dtypes)
Review comment:
Also feel free to make a separate PR to skip this in doctest:
https://github.com/apache/spark/blob/master/python/pyspark/pandas/typedef/typehints.py#L728-L729
by changing:
```diff
>>> ps.DataFrame[zip(pdf.index.names, pdf.index.dtypes),
zip(pdf.columns, pdf.dtypes)]
- ... # doctest: +ELLIPSIS
+ ... # doctest: +ELLIPSIS, +SKIP
```
--
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]