Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
BUG: datetime64 series reduces to nan when empty instead of nat #11245
Conversation
llllllllll
referenced
this pull request
in blaze/odo
Oct 5, 2015
Merged
ENH: Adds nan->pd.NaT edge #331
|
can I add a test in test_nanops and/or test_series |
|
also want to test for timedelta64/datetime64[ns, tz] too |
|
Sure, I will update this tonight when I get home |
jreback
added Bug Timeseries Dtypes Numeric Compat
labels
Oct 5, 2015
jreback
added this to the
0.17.1
milestone
Oct 5, 2015
|
pls also add a note in the 0.17.1 whatsnew bug section |
|
ping @jreback |
jreback
commented on the diff
Oct 7, 2015
| @@ -637,7 +619,7 @@ def _maybe_null_out(result, axis, mask): | ||
| else: | ||
| result = result.astype('f8') | ||
| result[null_mask] = np.nan | ||
| - else: | ||
| + elif result is not tslib.NaT: |
jreback
Contributor
|
jreback
commented on an outdated diff
Oct 7, 2015
jreback
commented on an outdated diff
Oct 7, 2015
| @@ -7960,6 +7960,11 @@ def test_datetime_timedelta_quantiles(self): | ||
| self.assertTrue(pd.isnull(Series([],dtype='M8[ns]').quantile(.5))) | ||
| self.assertTrue(pd.isnull(Series([],dtype='m8[ns]').quantile(.5))) | ||
| + def test_empty_timeseries_redections_return_nat(self): | ||
| + for dtype in ('m8[ns]', 'm8[ns]', 'M8[ns]', 'M8[ns, UTC]'): |
|
|
|
question for you. otherwise lgtm, pls squash to a single commit (I know different from other projects, just convention here) |
jreback
commented on an outdated diff
Oct 7, 2015
| - result = ensure_float(values.sum(axis, dtype=dtype_max)) | ||
| - result.fill(np.nan) | ||
| - except: | ||
| - result = np.nan | ||
| +def _nanminmax(meth, fill_value_typ): | ||
| + builtin = getattr(builtins, meth) | ||
| + | ||
| + @bottleneck_switch() | ||
| + def reduction(values, axis=None, skipna=True): | ||
| + values, mask, dtype, dtype_max = _get_values( | ||
| + values, | ||
| + skipna, | ||
| + fill_value_typ=fill_value_typ, | ||
| + ) | ||
| + | ||
| + # numpy 1.6.1 workaround in Python 3.x |
jreback
Contributor
|
llllllllll
commented on the diff
Oct 7, 2015
| - result = _wrap_results(result, dtype) | ||
| - return _maybe_null_out(result, axis, mask) | ||
| + result = _wrap_results(result, dtype) | ||
| + return _maybe_null_out(result, axis, mask) |
llllllllll
Contributor
|
|
Also I removed the workaround branch so hopefully the tests pass, otherwise we can put that branch back. |
|
ok looks good. I'll be merging things on friday after releasing 0.17.0 |
|
Thank you very much |
|
@llllllllll no thank you! |
|
@jreback just rebased against master, good to merge? |
jreback
and 1 other
commented on an outdated diff
Oct 10, 2015
|
we have lots of prs that are worked on at the same time |
|
Ah, that's a cool trick |
jreback
commented on an outdated diff
Oct 11, 2015
| @@ -74,3 +74,7 @@ Bug Fixes | ||
| - Bugs in ``to_excel`` with duplicate columns (:issue:`11007`, :issue:`10982`, :issue:`10970`) | ||
| +- min and max reductions on ``datetime64`` and ``timedelta64`` dtyped series now | ||
| + result in ``NaT`` and not ``nan`` (:issue:`11245`). |
jreback
Contributor
|
|
minor comment, ping when green |
|
tests are passing |
jreback
added a commit
that referenced
this pull request
Oct 11, 2015
|
|
jreback |
a4843cb
|
jreback
merged commit a4843cb
into pandas-dev:master
Oct 11, 2015
1 check passed
|
thank you sir! |
llllllllll commentedOct 5, 2015
I ran into some strange behavior with a series of dtype datetime64[ns] where I called max and got back a
nan. I think the correct behavior here is to returnnat. I looked through test_nanops but I am not sure where the correct place to put the test for this is.The new behavior is:
where the old behavior was: