Repository navigation
Commit 71f1edc
[SPARK-56016][PS] Preserve named Series columns in concat with ignore_index on pandas 3
### What changes were proposed in this pull request?
This PR updates pandas-on-Spark `concat` for row-wise concatenation of mixed `DataFrame` and `Series` inputs when `ignore_index=True`.
In pandas 2.x, pandas treats the `Series` input as an anonymous column named `0` in this case. In pandas 3.0+, pandas preserves the `Series` name and aligns it with matching `DataFrame` columns instead. pandas-on-Spark was still always converting mixed `Series` inputs to column `0`, which caused `pyspark.pandas.tests.test_namespace.NamespaceTests.test_concat_index_axis` to fail under pandas 3.
To match pandas behavior, this patch keeps the existing behavior for pandas 2.x, but preserves the `Series` name for mixed `DataFrame`/`Series` concatenation on pandas 3.0+.
This PR also updates the related namespace test to use `subTest(...)` for each concat case so the failing combination is easier to identify.
### Why are the changes needed?
Without this change, pandas-on-Spark produces incorrect columns for mixed `DataFrame`/`Series` concatenation with `ignore_index=True` on pandas 3.0+.
For example, concatenating a `DataFrame` with a named `Series` should reuse the `Series` name as the output column on pandas 3, but pandas-on-Spark instead creates a separate column `0`. That causes behavior differences from pandas and breaks the existing namespace concat test in the pandas 3 environment.
### Does this PR introduce _any_ user-facing change?
Yes, it will behave more like pandas 3.
### How was this patch tested?
The existing tests should pass.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-5)
Closes #54837 from ueshin/issues/SPARK-56016/concat.
Authored-by: Takuya Ueshin <ueshin@databricks.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>1 parent 6f3ece6 commit 71f1edc
2 files changed
Lines changed: 17 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2655 | 2655 | | |
2656 | 2656 | | |
2657 | 2657 | | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
2658 | 2662 | | |
2659 | 2663 | | |
2660 | 2664 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
370 | 374 | | |
371 | 375 | | |
372 | 376 | | |
373 | 377 | | |
374 | | - | |
| 378 | + | |
375 | 379 | | |
376 | 380 | | |
377 | 381 | | |
| |||
413 | 417 | | |
414 | 418 | | |
415 | 419 | | |
416 | | - | |
| 420 | + | |
417 | 421 | | |
418 | 422 | | |
419 | 423 | | |
| |||
424 | 428 | | |
425 | 429 | | |
426 | 430 | | |
427 | | - | |
| 431 | + | |
428 | 432 | | |
429 | 433 | | |
430 | 434 | | |
| |||
0 commit comments