-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: timedelta64(NaT) incorrectly treated as datetime in some dataframe ops #28049
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
Changes from 10 commits
3d24808
653967e
376c157
b60f9f8
ce0a36f
701fe31
90b92a0
9c12001
e142f58
b865438
71ef709
86070e1
e3514e4
222e636
fa48c27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -499,8 +499,19 @@ def column_op(a, b): | |
# in which case we specifically want to operate row-by-row | ||
assert right.index.equals(left.columns) | ||
|
||
def column_op(a, b): | ||
return {i: func(a.iloc[:, i], b.iloc[i]) for i in range(len(a.columns))} | ||
if right.dtype == "timedelta64[ns]": | ||
TomAugspurger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# ensure we treat NaT values as the correct dtype | ||
# Note: we do not do this unconditionally as it may be lossy or | ||
# expensive for EA dtypes. | ||
right = np.asarray(right) | ||
TomAugspurger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def column_op(a, b): | ||
return {i: func(a.iloc[:, i], b[i]) for i in range(len(a.columns))} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to double check - is the second argument to Side note - an alternate approach for by column iteration is to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, at this point
That runs in to difficulties if there are duplicate columns. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Might be worth looking at using |
||
|
||
else: | ||
|
||
def column_op(a, b): | ||
return {i: func(a.iloc[:, i], b.iloc[i]) for i in range(len(a.columns))} | ||
|
||
elif isinstance(right, ABCSeries): | ||
assert right.index.equals(left.index) # Handle other cases later | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can move to 1.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated+green