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: clip raising with na series bounds for datetimes or ea int #45161

Closed
wants to merge 4 commits into from

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 1, 2022

@phofl phofl added the Numeric Operations Arithmetic, Comparison, and Logical operations label Jan 1, 2022
if is_datetime64_any_dtype(self.dtype):
fill_value = Timestamp.max if method_name_le else Timestamp.min
elif is_extension_array_dtype(self.dtype):
fill_value = self.max() if method_name_le else self.min()
Copy link
Member Author

Choose a reason for hiding this comment

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

Is there a better way to do this for ea ints?

Copy link
Contributor

Choose a reason for hiding this comment

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

pandas/core/dtypes/missing/na_value_for_dtype

fill_value = np.inf if method.__name__ == "le" else -np.inf
method_name_le = method.__name__ == "le"
if is_datetime64_any_dtype(self.dtype):
fill_value = Timestamp.max if method_name_le else Timestamp.min
Copy link
Member

Choose a reason for hiding this comment

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

for dt64tz shouldn't fill_value be tzaware?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it possible to create a timezone aware Timestamp ts where ts > Timestamp.max would be true?

The fill value is not show in the result, it is just a placeholder

Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to create a timezone aware Timestamp ts where ts > Timestamp.max would be true?

no, that comparison would always raise TypeError

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm ok, then we could use the max case for timzeones too

@jreback jreback added this to the 1.5 milestone Jan 10, 2022
@@ -749,6 +749,7 @@ Numeric
- Bug in :class:`DataFrame` arithmetic ops with a subclass whose :meth:`_constructor` attribute is a callable other than the subclass itself (:issue:`43201`)
- Bug in arithmetic operations involving :class:`RangeIndex` where the result would have the incorrect ``name`` (:issue:`43962`)
- Bug in arithmetic operations involving :class:`Series` where the result could have the incorrect ``name`` when the operands having matching NA or matching tuple names (:issue:`44459`)
- Bug in :meth:`Series.clip` raising if bounds are a :class:`Series` with ``NA`` values for datetimes or nullable integer dtypes (:issue:`44785`)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you move to 1.5

if is_datetime64_any_dtype(self.dtype):
fill_value = Timestamp.max if method_name_le else Timestamp.min
elif is_extension_array_dtype(self.dtype):
fill_value = self.max() if method_name_le else self.min()
Copy link
Contributor

Choose a reason for hiding this comment

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

pandas/core/dtypes/missing/na_value_for_dtype

@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Feb 12, 2022
@jreback
Copy link
Contributor

jreback commented Feb 27, 2022

@phofl can you rebase

@phofl
Copy link
Member Author

phofl commented Feb 27, 2022

Sorry, forgot. Will do in the coming days

@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. Feel free to update and reopen when you have the time, but closing to clear out the queue

@mroeschke mroeschke closed this Jun 10, 2022
@phofl phofl deleted the 44785 branch April 27, 2023 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Numeric Operations Arithmetic, Comparison, and Logical operations Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Confusing error message when clipping datetimes
4 participants