-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
REGR: allow reindexing datetimelike with upcast / raise deprecation warning #44839
REGR: allow reindexing datetimelike with upcast / raise deprecation warning #44839
Conversation
Thanks @jorisvandenbossche just to be clear... s.reindex(
pd.date_range("2020-01-01", "2020-01-04", freq="1d"), fill_value=pd.Timedelta(0)
) on 1.2.5
and with this PR
so this is not restoring 1.2.5 behaviour exactly. However, the dtype is still so maybe should not yet close #42921 with this PR? |
moving this to 1.4. we don't need to backport this |
I moved this back to 1.3.5 milestone for now (let's discuss first before moving). It does fix a regression from 1.2->1.3. Code that worked on 1.2, is raising an error on 1.3. @simonjayhawkins you're right that None vs NaT is not exactly the same (I didn't notice that yet, can look into why that is the case), but it's also a much smaller difference compared to raising an error in 1.3
As you explained in that issue, it is expected that this doesn't give |
That's fine. we probably need to repeat/confirm this in the issue (that the expected in the OP is incorrect) so that it can be closed off. |
@jorisvandenbossche it may be a regression but this is delaying the long delayed release |
it's simply too late |
@jorisvandenbossche pls don't move this back |
will cases that go through ExtensionBlock.take_nd be affected/corrected? |
doc/source/whatsnew/v1.3.5.rst
Outdated
@@ -21,6 +21,7 @@ Fixed regressions | |||
- Fixed performance regression in :func:`read_csv` (:issue:`44106`) | |||
- Fixed regression in :meth:`Series.duplicated` and :meth:`Series.drop_duplicates` when Series has :class:`Categorical` dtype with boolean categories (:issue:`44351`) | |||
- Fixed regression in :meth:`.GroupBy.sum` with ``timedelta64[ns]`` dtype containing ``NaT`` failing to treat that value as NA (:issue:`42659`) | |||
- Fixed regression in :meth:`~Series.reindex` raising an error when using an incompatible fill value with a datetime-like dtype (or not raising a deprecation warning for using a ``datetime.date`` as fill value) (:issue:`42921`) |
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.
move to 1.4
@@ -113,6 +116,11 @@ def test_reindex_date_fill_value(self): | |||
) | |||
tm.assert_frame_equal(res, expected) | |||
|
|||
# only reindexing rows | |||
with tm.assert_produces_warning(FutureWarning): |
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.
why is this a warn?
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.
xref #44798 (comment).
@jorisvandenbossche maybe open dedicated issue for discussion/visibility.
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.
I think this PR can serve that purpose?
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.
could use a match=...
to clarify
No, because they are already strict in preserving the dtype anyway |
It isn't clear to me that this strictness is correct. i.e. in test_reindex_fill_value_datetimelike_upcast what happens if you add a couple of EA dtypes to the 'dtype' param? |
It has been like that for a long time (for ever?), and changing (or discussing) that is out of scope for this PR I think. |
Sure. Looks like ArrayManager tests are failing. |
@@ -94,6 +94,12 @@ def take_nd( | |||
""" | |||
if fill_value is lib.no_default: | |||
fill_value = na_value_for_dtype(arr.dtype, compat=False) | |||
elif isinstance(arr.dtype, np.dtype) and arr.dtype.kind in "mM": |
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.
does take_1d need to be changed to match?
@jorisvandenbossche needs rebase |
@phofl @jbrockmendel if one of you could rebase this |
…depr # Conflicts: # doc/source/whatsnew/v1.4.0.rst
rebased |
@jbrockmendel ok here? |
Nothing that should block this. I'd like to get a response here https://github.com/pandas-dev/pandas/pull/44839/files#r774813668 eventually |
The array_manager runs through take_1d which does not promote to object in case of incompatible fill values. Not familiar enough with the logic to decide on a fix here |
Yah, trying to make AM behavior consistent is a fool's errand. |
@jbrockmendel or @phofl can you rebase this |
@jbrockmendel or @phofl if you can rebase this |
merged master |
hmm a code check / pre-commit issue if you can fixup @jbrockmendel |
…h upcast / raise deprecation warning
@meeseeksdev backport 1.4.x |
Something went wrong ... Please have a look at my logs. |
… raise deprecation warning (#45406) Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Closes #42921
date
coercion (DEPR: casting date to dt64 in maybe_promote #39767) -> now this is also done for single-axis reindexing (xref PERF: avoid going through .values for reindexing both index/columns for ArrayManager #44798 (comment))pd.Timedelta
fails #42921 it is not fully clear if we really want to "fix" this regression)