Commit 94f5f4f
### What changes were proposed in this pull request?
This PR proposes to support `MultiIndex` for `to_series()`.
### Why are the changes needed?
So far, `to_series()` for `MultiIndex` is not working properly since the underlying data structure is different from Pandas and Spark. See the below examples in the next section for more detail.
### Does this PR introduce _any_ user-facing change?
**Before**
```python
>>> psmidx = ps.MultiIndex.from_tuples([("A", "B")])
>>> psmidx.to_series()
A B {'__index_level_0__': 'A', '__index_level_1__'...
C {'__index_level_0__': 'A', '__index_level_1__'...
B C {'__index_level_0__': 'B', '__index_level_1__'...
dtype: object
```
**After**
```python
>>> psmidx = ps.MultiIndex.from_tuples([("A", "B")])
>>> psmidx.to_series()
A B [A, B]
C [A, C]
B C [B, C]
dtype: object
```
### How was this patch tested?
Enabling the existing UT.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #43228 from itholic/SPARK-43704.
Authored-by: Haejoon Lee <haejoon.lee@databricks.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
1 parent 8d3199d commit 94f5f4f
File tree
3 files changed
+21
-9
lines changed- python/pyspark/pandas
- indexes
- tests/connect/indexes
3 files changed
+21
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
919 | | - | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
920 | 932 | | |
921 | 933 | | |
922 | 934 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1077 | 1077 | | |
1078 | 1078 | | |
1079 | 1079 | | |
1080 | | - | |
| 1080 | + | |
1081 | 1081 | | |
1082 | 1082 | | |
1083 | | - | |
1084 | | - | |
1085 | | - | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
1086 | 1090 | | |
1087 | 1091 | | |
1088 | 1092 | | |
| |||
Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | 32 | | |
37 | 33 | | |
38 | 34 | | |
| |||
0 commit comments