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: infer-objects raising for bytes Series #50067

Merged
merged 4 commits into from
Dec 8, 2022
Merged

Conversation

phofl
Copy link
Member

@phofl phofl commented Dec 5, 2022

cc @jbrockmendel

@phofl phofl added Dtype Conversions Unexpected or buggy dtype conversions Regression Functionality that used to work in a prior pandas version labels Dec 5, 2022
@phofl phofl added this to the 2.0 milestone Dec 5, 2022
@@ -1969,6 +1969,9 @@ def convert(
attempt to cast any object types to better types return a copy of
the block (if copy = True) by definition we ARE an ObjectBlock!!!!!
"""
if self.dtype != object:
return [self]
Copy link
Member

Choose a reason for hiding this comment

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

i think this may need to make a copy in some cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you sure?

ser = Series(["a"], dtype="object")
result = ser.infer_objects()
result.iloc[0] = "c"
print(ser)

this updates ser as well, same as the bytes version. If we add a copy, the bytes version would not update anymore

Copy link
Member

Choose a reason for hiding this comment

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

  1. infer_objects in principle makes a copy in cases where it doesn't do inference. 2) I don't think that's what most users (or our internal usages) actually want. 3) ATM the ObjectBlock case that doesn't do inference doesn't make a copy, which is inconsistent with other dtypes. 4) i think adding a copy keyword makes sense xref ENH/PERF: copy=True keyword in methods where copy=False can improve perf #48141, but adding copy keywords in general got pushback recently

Copy link
Member

Choose a reason for hiding this comment

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

I guess we can ignore this since were not consistent about it anyway

Copy link
Member Author

Choose a reason for hiding this comment

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

Can address in follow up

@jbrockmendel
Copy link
Member

Needs rebase

phofl added 2 commits December 7, 2022 20:36
# Conflicts:
#	pandas/tests/series/methods/test_infer_objects.py
# Conflicts:
#	pandas/tests/series/methods/test_infer_objects.py
@phofl
Copy link
Member Author

phofl commented Dec 7, 2022

rebased

@jbrockmendel jbrockmendel merged commit 0ad74d7 into pandas-dev:main Dec 8, 2022
@jbrockmendel
Copy link
Member

thanks @phofl

@phofl phofl deleted the 49650 branch December 8, 2022 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: maybe_convert_objects fails for byte series
2 participants