|
14 | 14 | import pandas as pd
|
15 | 15 | import pandas.tseries.offsets as offsets
|
16 | 16 | import pandas.util.testing as tm
|
17 |
| -import pandas.util._test_decorators as td |
18 | 17 | from pandas import (Series, DataFrame, Panel, Index, isna,
|
19 | 18 | notna, Timestamp)
|
20 | 19 |
|
21 |
| -from pandas.core.dtypes.generic import ABCSeries, ABCDataFrame |
22 | 20 | from pandas.compat import range, lrange, zip, product, OrderedDict
|
23 | 21 | from pandas.errors import UnsupportedFunctionCall
|
24 | 22 | from pandas.core.groupby.groupby import DataError
|
|
28 | 26 | from pandas.core.indexes.datetimes import date_range
|
29 | 27 | from pandas.tseries.offsets import Minute, BDay
|
30 | 28 | from pandas.core.indexes.period import period_range, PeriodIndex, Period
|
31 |
| -from pandas.core.resample import (DatetimeIndex, TimeGrouper, |
32 |
| - DatetimeIndexResampler) |
| 29 | +from pandas.core.resample import DatetimeIndex, TimeGrouper |
33 | 30 | from pandas.core.indexes.timedeltas import timedelta_range, TimedeltaIndex
|
34 | 31 | from pandas.util.testing import (assert_series_equal, assert_almost_equal,
|
35 | 32 | assert_frame_equal, assert_index_equal)
|
@@ -84,122 +81,6 @@ def test_api(self):
|
84 | 81 | assert isinstance(result, DataFrame)
|
85 | 82 | assert len(result) == 217
|
86 | 83 |
|
87 |
| - def test_api_changes_v018(self): |
88 |
| - |
89 |
| - # change from .resample(....., how=...) |
90 |
| - # to .resample(......).how() |
91 |
| - |
92 |
| - r = self.series.resample('H') |
93 |
| - assert isinstance(r, DatetimeIndexResampler) |
94 |
| - |
95 |
| - for how in ['sum', 'mean', 'prod', 'min', 'max', 'var', 'std']: |
96 |
| - with tm.assert_produces_warning(FutureWarning, |
97 |
| - check_stacklevel=False): |
98 |
| - result = self.series.resample('H', how=how) |
99 |
| - expected = getattr(self.series.resample('H'), how)() |
100 |
| - tm.assert_series_equal(result, expected) |
101 |
| - |
102 |
| - with tm.assert_produces_warning(FutureWarning, |
103 |
| - check_stacklevel=False): |
104 |
| - result = self.series.resample('H', how='ohlc') |
105 |
| - expected = self.series.resample('H').ohlc() |
106 |
| - tm.assert_frame_equal(result, expected) |
107 |
| - |
108 |
| - # compat for pandas-like methods |
109 |
| - for how in ['sort_values', 'isna']: |
110 |
| - with tm.assert_produces_warning(FutureWarning, |
111 |
| - check_stacklevel=False): |
112 |
| - getattr(r, how)() |
113 |
| - |
114 |
| - # invalids as these can be setting operations |
115 |
| - r = self.series.resample('H') |
116 |
| - pytest.raises(ValueError, lambda: r.iloc[0]) |
117 |
| - pytest.raises(ValueError, lambda: r.iat[0]) |
118 |
| - pytest.raises(ValueError, lambda: r.loc[0]) |
119 |
| - pytest.raises(ValueError, lambda: r.loc[ |
120 |
| - Timestamp('2013-01-01 00:00:00', offset='H')]) |
121 |
| - pytest.raises(ValueError, lambda: r.at[ |
122 |
| - Timestamp('2013-01-01 00:00:00', offset='H')]) |
123 |
| - |
124 |
| - def f(): |
125 |
| - r[0] = 5 |
126 |
| - |
127 |
| - pytest.raises(ValueError, f) |
128 |
| - |
129 |
| - # str/repr |
130 |
| - r = self.series.resample('H') |
131 |
| - with tm.assert_produces_warning(None): |
132 |
| - str(r) |
133 |
| - with tm.assert_produces_warning(None): |
134 |
| - repr(r) |
135 |
| - |
136 |
| - with tm.assert_produces_warning(FutureWarning, |
137 |
| - check_stacklevel=False): |
138 |
| - tm.assert_numpy_array_equal(np.array(r), np.array(r.mean())) |
139 |
| - |
140 |
| - # masquerade as Series/DataFrame as needed for API compat |
141 |
| - assert isinstance(self.series.resample('H'), ABCSeries) |
142 |
| - assert not isinstance(self.frame.resample('H'), ABCSeries) |
143 |
| - assert not isinstance(self.series.resample('H'), ABCDataFrame) |
144 |
| - assert isinstance(self.frame.resample('H'), ABCDataFrame) |
145 |
| - |
146 |
| - # bin numeric ops |
147 |
| - for op in ['__add__', '__mul__', '__truediv__', '__div__', '__sub__']: |
148 |
| - |
149 |
| - if getattr(self.series, op, None) is None: |
150 |
| - continue |
151 |
| - r = self.series.resample('H') |
152 |
| - |
153 |
| - with tm.assert_produces_warning(FutureWarning, |
154 |
| - check_stacklevel=False): |
155 |
| - assert isinstance(getattr(r, op)(2), Series) |
156 |
| - |
157 |
| - # unary numeric ops |
158 |
| - for op in ['__pos__', '__neg__', '__abs__', '__inv__']: |
159 |
| - |
160 |
| - if getattr(self.series, op, None) is None: |
161 |
| - continue |
162 |
| - r = self.series.resample('H') |
163 |
| - |
164 |
| - with tm.assert_produces_warning(FutureWarning, |
165 |
| - check_stacklevel=False): |
166 |
| - assert isinstance(getattr(r, op)(), Series) |
167 |
| - |
168 |
| - # comparison ops |
169 |
| - for op in ['__lt__', '__le__', '__gt__', '__ge__', '__eq__', '__ne__']: |
170 |
| - r = self.series.resample('H') |
171 |
| - |
172 |
| - with tm.assert_produces_warning(FutureWarning, |
173 |
| - check_stacklevel=False): |
174 |
| - assert isinstance(getattr(r, op)(2), Series) |
175 |
| - |
176 |
| - # IPython introspection shouldn't trigger warning GH 13618 |
177 |
| - for op in ['_repr_json', '_repr_latex', |
178 |
| - '_ipython_canary_method_should_not_exist_']: |
179 |
| - r = self.series.resample('H') |
180 |
| - with tm.assert_produces_warning(None): |
181 |
| - getattr(r, op, None) |
182 |
| - |
183 |
| - # getitem compat |
184 |
| - df = self.series.to_frame('foo') |
185 |
| - |
186 |
| - # same as prior versions for DataFrame |
187 |
| - pytest.raises(KeyError, lambda: df.resample('H')[0]) |
188 |
| - |
189 |
| - # compat for Series |
190 |
| - # but we cannot be sure that we need a warning here |
191 |
| - with tm.assert_produces_warning(FutureWarning, |
192 |
| - check_stacklevel=False): |
193 |
| - result = self.series.resample('H')[0] |
194 |
| - expected = self.series.resample('H').mean()[0] |
195 |
| - assert result == expected |
196 |
| - |
197 |
| - with tm.assert_produces_warning(FutureWarning, |
198 |
| - check_stacklevel=False): |
199 |
| - result = self.series.resample('H')['2005-01-09 23:00:00'] |
200 |
| - expected = self.series.resample('H').mean()['2005-01-09 23:00:00'] |
201 |
| - assert result == expected |
202 |
| - |
203 | 84 | def test_groupby_resample_api(self):
|
204 | 85 |
|
205 | 86 | # GH 12448
|
@@ -251,23 +132,6 @@ def test_pipe(self):
|
251 | 132 | result = r.pipe(lambda x: x.max() - x.mean())
|
252 | 133 | tm.assert_frame_equal(result, expected)
|
253 | 134 |
|
254 |
| - @td.skip_if_no_mpl |
255 |
| - def test_plot_api(self): |
256 |
| - # .resample(....).plot(...) |
257 |
| - # hitting warnings |
258 |
| - # GH 12448 |
259 |
| - s = Series(np.random.randn(60), |
260 |
| - index=date_range('2016-01-01', periods=60, freq='1min')) |
261 |
| - with tm.assert_produces_warning(FutureWarning, |
262 |
| - check_stacklevel=False): |
263 |
| - result = s.resample('15min').plot() |
264 |
| - tm.assert_is_valid_plot_return_object(result) |
265 |
| - |
266 |
| - with tm.assert_produces_warning(FutureWarning, |
267 |
| - check_stacklevel=False): |
268 |
| - result = s.resample('15min', how='sum').plot() |
269 |
| - tm.assert_is_valid_plot_return_object(result) |
270 |
| - |
271 | 135 | def test_getitem(self):
|
272 | 136 |
|
273 | 137 | r = self.frame.resample('H')
|
@@ -301,15 +165,6 @@ def test_attribute_access(self):
|
301 | 165 | r = self.frame.resample('H')
|
302 | 166 | tm.assert_series_equal(r.A.sum(), r['A'].sum())
|
303 | 167 |
|
304 |
| - # getting |
305 |
| - pytest.raises(AttributeError, lambda: r.F) |
306 |
| - |
307 |
| - # setting |
308 |
| - def f(): |
309 |
| - r.F = 'bah' |
310 |
| - |
311 |
| - pytest.raises(ValueError, f) |
312 |
| - |
313 | 168 | def test_api_compat_before_use(self):
|
314 | 169 |
|
315 | 170 | # make sure that we are setting the binner
|
@@ -3012,23 +2867,6 @@ def setup_method(self, method):
|
3012 | 2867 | freq='s',
|
3013 | 2868 | periods=40))
|
3014 | 2869 |
|
3015 |
| - def test_back_compat_v180(self): |
3016 |
| - |
3017 |
| - df = self.frame |
3018 |
| - for how in ['sum', 'mean', 'prod', 'min', 'max', 'var', 'std']: |
3019 |
| - with tm.assert_produces_warning(FutureWarning, |
3020 |
| - check_stacklevel=False): |
3021 |
| - result = df.groupby('A').resample('4s', how=how) |
3022 |
| - expected = getattr(df.groupby('A').resample('4s'), how)() |
3023 |
| - assert_frame_equal(result, expected) |
3024 |
| - |
3025 |
| - with tm.assert_produces_warning(FutureWarning, |
3026 |
| - check_stacklevel=False): |
3027 |
| - result = df.groupby('A').resample('4s', how='mean', |
3028 |
| - fill_method='ffill') |
3029 |
| - expected = df.groupby('A').resample('4s').mean().ffill() |
3030 |
| - assert_frame_equal(result, expected) |
3031 |
| - |
3032 | 2870 | def test_tab_complete_ipython6_warning(self, ip):
|
3033 | 2871 | from IPython.core.completer import provisionalcompleter
|
3034 | 2872 | code = dedent("""\
|
|
0 commit comments