-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PR for Pandas issue #14872 / fillna() TZ datetime64 rounded #14905
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
Conversation
this goes way overboard see the pull request which closed the original issue |
The changes in request #6587 added "dtype in _DATELIKE_DTYPES" to the method selection in the backfill_2d function (now in missing.py),
I initially tried adding an extra is_datetime64tz_dtype() to this line with no success. After tracing the process with pdb I found that the values are already coerced to integers in pandas/core/internals.py,
before being passed to /pandas/core/missing.interpolate_2d and then to backfill_2d. The dtype information is passed as dtype=datetime64[ns, UTC]. When it gets to these lines in the backfill_2d function,
the return is always false because datetime64[ns, UTC] is not in _DATELIKE_DTYPES and the 'values' are integers. Another way would be to either replace datetime64[ns, UTC] with datetime64[ns] before we get to this line or skip the coercion somehow. Unless I am missing something. |
so this should simply be changed to pass the actual value (and not coerced ones) when this is called and drop al of the _DATELIKE_DTYPES that is really old code use the is_datetime64_dtype and is_datetime64tz_dtype |
actually you just need to check the dtype instead (of the values) e.g.
|
Current coverage is 84.57% (diff: 75.00%)@@ master #14905 diff @@
==========================================
Files 144 144
Lines 51043 51058 +15
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43160 43181 +21
+ Misses 7883 7877 -6
Partials 0 0
|
Done! I was indeed missing something. Thank you for the feedback! |
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.
pls add a whatsnew entry (0.19.2) ok if u can make these changes in next day or so
|
||
filled = data.fillna(method='bfill') | ||
|
||
expected = pd.Series([datetime.datetime(2016, 12, 12, 22, 24, 6, 100001, |
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.
this test needs to go in test_missing (search and out it with other similar tests)
@@ -908,6 +911,24 @@ def test_interp_timedelta64(self): | |||
index=pd.to_timedelta([1, 2, 4])) | |||
assert_series_equal(result, expected) | |||
|
|||
# GH 14872 | |||
def test_dtype_utc(): |
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.
needs to take self
thanks! |
closes pandas-dev#14872 Author: Rodolfo Fernandez <[email protected]> Closes pandas-dev#14905 from RodolfoRFR/pandas-14872-e and squashes the following commits: 18802b4 [Rodolfo Fernandez] added 'self' to test_dtype_utc function in pandas/tests/series/test_missing e0c6c7c [Rodolfo Fernandez] added line to whatsnew v0.19.2 and test to test_missing.py in series folder e4ba7e0 [Rodolfo Fernandez] removed all references to _DATELIKE_DTYPES from /pandas/core/missing.py 5d37ce8 [Rodolfo Fernandez] added is_datetime64tz_dtype and changed evaluation from 'values' to dtype 19eecb2 [Rodolfo Fernandez] fixed style errors using flake8 59b91a1 [Rodolfo Fernandez] test modified 5a59eac [Rodolfo Fernandez] test modified bc68bf7 [Rodolfo Fernandez] test modified ba83fc8 [Rodolfo Fernandez] test b7358de [Rodolfo Fernandez] bug fixed
closes pandas-dev#14872 Author: Rodolfo Fernandez <[email protected]> Closes pandas-dev#14905 from RodolfoRFR/pandas-14872-e and squashes the following commits: 18802b4 [Rodolfo Fernandez] added 'self' to test_dtype_utc function in pandas/tests/series/test_missing e0c6c7c [Rodolfo Fernandez] added line to whatsnew v0.19.2 and test to test_missing.py in series folder e4ba7e0 [Rodolfo Fernandez] removed all references to _DATELIKE_DTYPES from /pandas/core/missing.py 5d37ce8 [Rodolfo Fernandez] added is_datetime64tz_dtype and changed evaluation from 'values' to dtype 19eecb2 [Rodolfo Fernandez] fixed style errors using flake8 59b91a1 [Rodolfo Fernandez] test modified 5a59eac [Rodolfo Fernandez] test modified bc68bf7 [Rodolfo Fernandez] test modified ba83fc8 [Rodolfo Fernandez] test b7358de [Rodolfo Fernandez] bug fixed (cherry picked from commit f3c5a42)
closes pandas-dev#14872 Author: Rodolfo Fernandez <[email protected]> Closes pandas-dev#14905 from RodolfoRFR/pandas-14872-e and squashes the following commits: 18802b4 [Rodolfo Fernandez] added 'self' to test_dtype_utc function in pandas/tests/series/test_missing e0c6c7c [Rodolfo Fernandez] added line to whatsnew v0.19.2 and test to test_missing.py in series folder e4ba7e0 [Rodolfo Fernandez] removed all references to _DATELIKE_DTYPES from /pandas/core/missing.py 5d37ce8 [Rodolfo Fernandez] added is_datetime64tz_dtype and changed evaluation from 'values' to dtype 19eecb2 [Rodolfo Fernandez] fixed style errors using flake8 59b91a1 [Rodolfo Fernandez] test modified 5a59eac [Rodolfo Fernandez] test modified bc68bf7 [Rodolfo Fernandez] test modified ba83fc8 [Rodolfo Fernandez] test b7358de [Rodolfo Fernandez] bug fixed
Hi Jeff,
The change adds a "datetime64[ns, UTC]" object to the _DATELIKE_DTYPES set in pandas/types/common.py.
No such object existed in this set and that is the reason the wrong method was executed on the inputs.
Object is created with "DatetimeTZDtype.new"
Thanks,
Rodolfo
git diff upstream/master | flake8 --diff
(returns the same number of skips, errors and failures before changes)