Skip to content

TST: regression test for concat with keys and mixed-freq PeriodIndex columns#65439

Merged
mroeschke merged 3 commits into
pandas-dev:mainfrom
jbrockmendel:bug-51489
May 7, 2026
Merged

TST: regression test for concat with keys and mixed-freq PeriodIndex columns#65439
mroeschke merged 3 commits into
pandas-dev:mainfrom
jbrockmendel:bug-51489

Conversation

@jbrockmendel
Copy link
Copy Markdown
Member

Summary

  • Closes BUG: Concat 2 dataframes with different PeriodIndex raises an exception when using keys parameter #51489.
  • The originally-reported failure (pd.concat([q_df, y_df], keys=[...], axis=1) raising IncompatibleFrequency when the column PeriodIndex objects have different freq) no longer reproduces on main.
  • It was fixed as a side effect of API: IncompatibleFrequency subclass TypeError #61875, which made IncompatibleFrequency subclass TypeError. The Categorical.__init__ factorize path that concat uses already had try: factorize(values, sort=True) except TypeError: factorize(values, sort=False), so the freq mismatch is now caught and falls back to an unsorted object-dtype level, which is the desired behavior.
  • Adds a regression test in TestPeriodConcat covering the reproducer from the issue.

Test plan

  • pytest pandas/tests/reshape/concat/test_datetimes.py::TestPeriodConcat -xvs

🤖 Generated with Claude Code

@jbrockmendel jbrockmendel marked this pull request as ready for review May 5, 2026 19:03
@jbrockmendel jbrockmendel added the Testing pandas testing functions or related to the test suite label May 7, 2026
@mroeschke mroeschke added this to the 3.1 milestone May 7, 2026
@mroeschke mroeschke merged commit bc7ce13 into pandas-dev:main May 7, 2026
53 checks passed
@mroeschke
Copy link
Copy Markdown
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the bug-51489 branch May 7, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Testing pandas testing functions or related to the test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Concat 2 dataframes with different PeriodIndex raises an exception when using keys parameter

2 participants