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: Fix multiplying Timedelta Series with a pandas nullable dtype Series #58375

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kvnwng11
Copy link

@kvnwng11 kvnwng11 commented Apr 22, 2024

Tests were added, but raise an error. Does anyone know how to fix it?

Screenshot 2024-04-22 at 3 01 50 PM

This is my first pull request, please let me know if I need to change anything :)

@mroeschke mroeschke added Numeric Operations Arithmetic, Comparison, and Logical operations Timedelta Timedelta data type NA - MaskedArrays Related to pd.NA and nullable extension arrays labels Apr 23, 2024
@@ -365,6 +365,7 @@ Timedelta
^^^^^^^^^
- Accuracy improvement in :meth:`Timedelta.to_pytimedelta` to round microseconds consistently for large nanosecond based Timedelta (:issue:`57841`)
- Bug in :meth:`DataFrame.cumsum` which was raising ``IndexError`` if dtype is ``timedelta64[ns]`` (:issue:`57956`)
- Bug in :meth:`TimedeltaArray._simple_new` which was raising ``AssertionError`` When multiplying a Series with a timedelta64 dtype with another Series that uses any of the pandas nullable dtypes ``('Int8', 'Int16', 'Int32', 'Int64', 'UInt8', 'UInt16', 'UInt32', 'UInt64', 'Float32', 'Float64', or 'boolean')`` (:issue:`58054`)
Copy link
Member

Choose a reason for hiding this comment

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

don't reference _simple_new or even TimedeltaArray, just the relevant dtypes in Series/DataFrame

@@ -492,6 +494,16 @@ def __mul__(self, other) -> Self:
result = np.array(result)
return type(self)._simple_new(result, dtype=result.dtype)

if is_bool_dtype(other.dtype) or is_numeric_dtype(other.dtype):
Copy link
Member

Choose a reason for hiding this comment

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

instead of doing this here, check for BaseMaskedArray and return NotImplemented

td_series = Series([timedelta(hours=1)])
other = Series([True])

pandas_types = [
Copy link
Member

Choose a reason for hiding this comment

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

use a fixture or pytest.mark.parametrize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NA - MaskedArrays Related to pd.NA and nullable extension arrays Numeric Operations Arithmetic, Comparison, and Logical operations Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: AssertionError when multiplying timedelta Series with a pandas nullable dtype Series
3 participants