thangnd197 opened a new pull request #34112: URL: https://github.com/apache/spark/pull/34112
Lead-authored-by: dgd-contributor <[email protected]> Co-authored-by: thangnd197 <[email protected]> ### What changes were proposed in this pull request? Support multi-index in new syntax to specify index data type ### Why are the changes needed? Support multi-index in new syntax to specify index data type https://issues.apache.org/jira/browse/SPARK-36707 ### Does this PR introduce _any_ user-facing change? After this PR user can use ``` python >>> ps.DataFrame[[int, int],[int, int]] typing.Tuple[pyspark.pandas.typedef.typehints.IndexNameType, pyspark.pandas.typedef.typehints.IndexNameType, pyspark.pandas.typedef.typehints.NameType, pyspark.pandas.typedef.typehints.NameType] >>> arrays = [[1, 1, 2], ['red', 'blue', 'red']] >>> idx = pd.MultiIndex.from_arrays(arrays, names=('number', 'color')) >>> pdf = pd.DataFrame([[1,2,3],[2,3,4],[4,5,6]], index=idx, columns=["a", "b", "c"]) >>> ps.DataFrame[pdf.index.dtypes, pdf.dtypes] typing.Tuple[pyspark.pandas.typedef.typehints.IndexNameType, pyspark.pandas.typedef.typehints.IndexNameType, pyspark.pandas.typedef.typehints.NameType, pyspark.pandas.typedef.typehints.NameType, pyspark.pandas.typedef.typehints.NameType] >>> ps.DataFrame[[("index", int), ("index-2", int)], [("id", int), ("A", int)]] typing.Tuple[pyspark.pandas.typedef.typehints.IndexNameType, pyspark.pandas.typedef.typehints.IndexNameType, pyspark.pandas.typedef.typehints.NameType, pyspark.pandas.typedef.typehints.NameType] >>> ps.DataFrame[zip(pdf.index.names, pdf.index.dtypes), zip(pdf.columns, pdf.dtypes)] typing.Tuple[pyspark.pandas.typedef.typehints.IndexNameType, pyspark.pandas.typedef.typehints.IndexNameType, pyspark.pandas.typedef.typehints.NameType, pyspark.pandas.typedef.typehints.NameType, pyspark.pandas.typedef.typehints.NameType] ``` ### How was this patch tested? exist tests -- 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]
