Skip to content
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

BUG: Groupby not keeping object dtype when infer string is set #55620

Merged
merged 1 commit into from
Oct 22, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Oct 21, 2023

  • 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.

@phofl phofl requested a review from rhshadrach as a code owner October 21, 2023 19:13
@phofl phofl added this to the 2.1.2 milestone Oct 21, 2023
@phofl phofl added Strings String extension data type and string data Arrow pyarrow functionality labels Oct 21, 2023
Copy link
Member

@rhshadrach rhshadrach 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

@@ -1904,8 +1904,7 @@ def _agg_py_fallback(
ser = Series(values, copy=False)
else:
# We only get here with values.dtype == object
# TODO: special case not needed with ArrayManager
df = DataFrame(values.T)
df = DataFrame(values.T, dtype=values.dtype)
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps slightly out of scope, but I think it'd be good to add an assert on values.dtype == object here

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I'd rather keep this out of here

@rhshadrach rhshadrach added Groupby Dtype Conversions Unexpected or buggy dtype conversions labels Oct 22, 2023
@rhshadrach
Copy link
Member

Is this a regression with no related issue?

@rhshadrach rhshadrach added the Bug label Oct 22, 2023
@phofl
Copy link
Member Author

phofl commented Oct 22, 2023

I am working on a build that uses arrow backed strings by default, but this turns up dozens of bugs related to either the new string dtype we added for 2.1 or arrow strings more generally, not opening issues since I am fixing them when I come across them

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

lgtm

@rhshadrach rhshadrach merged commit 839ed72 into pandas-dev:main Oct 22, 2023
50 of 51 checks passed
@rhshadrach
Copy link
Member

Thanks @phofl

meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Oct 22, 2023
@phofl phofl deleted the groupby_dup_columns branch October 22, 2023 15:22
mroeschke pushed a commit that referenced this pull request Oct 22, 2023
…type when infer string is set) (#55629)

Backport PR #55620: BUG: Groupby not keeping object dtype when infer string is set

Co-authored-by: Patrick Hoefler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Bug Dtype Conversions Unexpected or buggy dtype conversions Groupby Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants