Skip to content

BUG: DataFrame.explode fails with str dtype #61623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 24, 2025

Conversation

rhshadrach
Copy link
Member

@rhshadrach rhshadrach commented Jun 10, 2025

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

This operation works on all other dtypes, e.g.

df = pd.DataFrame({"a": [1, 2]})
print(df.explode(column="a"))
#    a
# 0  1
# 1  2

@rhshadrach rhshadrach added this to the 2.3.1 milestone Jun 10, 2025
@rhshadrach rhshadrach added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Strings String extension data type and string data Bug labels Jun 10, 2025
Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'd personally have the new release notes template added in a separate issue, but no big deal.

Btw, did we have problems before to have the result is not df assert? I haven't used it before, it'd be good to understand in which tests it make sense. Thanks!

@rhshadrach
Copy link
Member Author

@datapythonista

Btw, did we have problems before to have the result is not df assert? I haven't used it before, it'd be good to understand in which tests it make sense. Thanks!

I think it makes sense to check this when we have a no-op that should return a copy. If the operation modifies the data (which is the case for the vast majority of tests), I don't think it needs to be checked.

@rhshadrach
Copy link
Member Author

@datapythonista - fixed up the docs build, this should be ready.

@rhshadrach rhshadrach requested a review from mroeschke June 24, 2025 03:00
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jorisvandenbossche jorisvandenbossche merged commit 73db25d into pandas-dev:main Jun 24, 2025
44 checks passed
Copy link

lumberbot-app bot commented Jun 24, 2025

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 2.3.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 73db25d585a12e587beffef83449dbdd5d16d0f6
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #61623: BUG: DataFrame.explode fails with str dtype'
  1. Push to a named branch:
git push YOURFORK 2.3.x:auto-backport-of-pr-61623-on-2.3.x
  1. Create a PR against branch 2.3.x, I would have named this PR:

"Backport PR #61623 on branch 2.3.x (BUG: DataFrame.explode fails with str dtype)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@jorisvandenbossche
Copy link
Member

Backport -> #61699

jorisvandenbossche added a commit that referenced this pull request Jun 24, 2025
…#61699)

BUG: DataFrame.explode fails with str dtype (#61623)

Co-authored-by: Richard Shadrach <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants