Skip to content

TST: Test resampling with NaT #13164

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

Closed
wants to merge 1 commit into from
Closed

Conversation

evectant
Copy link
Contributor

@sinhrks
Copy link
Member

sinhrks commented May 12, 2016

Thanks. Can you also add TimedeltaIndex and PeriodIndex?

@sinhrks sinhrks added Testing pandas testing functions or related to the test suite Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Resample resample method labels May 12, 2016
@sinhrks sinhrks added this to the 0.18.2 milestone May 12, 2016
@@ -1426,6 +1426,32 @@ def test_to_xarray(self):
expected,
check_index_type=False)

def test_resample_with_nat(self):
# GH 13020
index = pd.DatetimeIndex([pd.NaT,
Copy link
Contributor

Choose a reason for hiding this comment

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

move all of these to tests/tseries/test_resample.py

@codecov-io
Copy link

codecov-io commented May 13, 2016

Current coverage is 84.12%

Merging #13164 into master will decrease coverage by <.01%

@@             master     #13164   diff @@
==========================================
  Files           138        138          
  Lines         50388      50380     -8   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          42386      42379     -7   
+ Misses         8002       8001     -1   
  Partials          0          0          
  1. 2 files (not in diff) in pandas/tseries were modified. more
    • Misses +1
    • Hits -2
  2. 2 files (not in diff) in pandas/tools were modified. more
    • Hits -4
  3. 4 files (not in diff) in pandas were modified. more
    • Misses -2
    • Hits -1

Powered by Codecov. Last updated by 4e4a7d9...6d47c87

@jreback
Copy link
Contributor

jreback commented May 16, 2016

@evectant can you rebase & update

@evectant
Copy link
Contributor Author

evectant commented May 16, 2016

@sinhrks Those don't seem to be very tolerant to NaT. I'm not sure what behavior we should pin down here.

In [2]: dti = pd.DatetimeIndex(['1970-01-01 00:00:00', pd.NaT, '1970-01-01 00:00:02'])

In [3]: pd.DataFrame([2, 3, 5], dti).resample('1s').mean()
Out[3]: 
                       0
1970-01-01 00:00:00  2.0
1970-01-01 00:00:01  NaN
1970-01-01 00:00:02  5.0
In [4]: tdi = pd.to_timedelta(['0s', pd.NaT, '2s'])

In [5]: pd.DataFrame([2, 3, 5], tdi).resample('1s').mean()
...
MemoryError:
In [6]: pi = pd.PeriodIndex(['1970-01-01 00:00:00', pd.NaT, '1970-01-01 00:00:02'], freq='S')

In [7]: pd.DataFrame([2, 3, 5], pi).resample('1s').mean()
...
ValueError: Start and end must not be NaT

@@ -2839,6 +2839,32 @@ def test_aggregate_with_nat(self):
# if NaT is included, 'var', 'std', 'mean', 'first','last'
# and 'nth' doesn't work yet

def test_resample_with_nat(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

if you move these to Base and use .create_series() you will get testing for free for all of the sub-classes (DTI, PeriodIndex, TimedeltaIndex)

Copy link
Contributor Author

@evectant evectant May 16, 2016

Choose a reason for hiding this comment

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

Would it be helpful here? All three index types seem to handle NaT differently (see examples above).

@sinhrks
Copy link
Member

sinhrks commented May 18, 2016

@evectant Thx to confirm. It's gr8 if you can fix, otherwise keep #13020 open or submit new issue for tracking.

@evectant
Copy link
Contributor Author

@sinhrks @jreback I think there are three different issues here:

So can this one be merged and #13020 closed?

@jreback jreback closed this in 4b50149 May 18, 2016
@jreback
Copy link
Contributor

jreback commented May 18, 2016

thanks @evectant

merged.

when you work on the other too resample-with-nat issues, ideally we move this test to Base (so it cycles thru all index types); then these are all in 1 place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Resample resample method Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants