@@ -84,122 +84,6 @@ def test_api(self):
8484 assert isinstance (result , DataFrame )
8585 assert len (result ) == 217
8686
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-
20387 def test_groupby_resample_api (self ):
20488
20589 # GH 12448
@@ -251,23 +135,6 @@ def test_pipe(self):
251135 result = r .pipe (lambda x : x .max () - x .mean ())
252136 tm .assert_frame_equal (result , expected )
253137
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-
271138 def test_getitem (self ):
272139
273140 r = self .frame .resample ('H' )
@@ -301,15 +168,6 @@ def test_attribute_access(self):
301168 r = self .frame .resample ('H' )
302169 tm .assert_series_equal (r .A .sum (), r ['A' ].sum ())
303170
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-
313171 def test_api_compat_before_use (self ):
314172
315173 # make sure that we are setting the binner
@@ -3012,23 +2870,6 @@ def setup_method(self, method):
30122870 freq = 's' ,
30132871 periods = 40 ))
30142872
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-
30322873 def test_tab_complete_ipython6_warning (self , ip ):
30332874 from IPython .core .completer import provisionalcompleter
30342875 code = dedent ("""\
0 commit comments