@@ -2236,7 +2236,7 @@ def last_valid_index(self):
2236
2236
#----------------------------------------------------------------------
2237
2237
# Time series-oriented methods
2238
2238
2239
- def shift (self , periods , offset = None , ** kwds ):
2239
+ def shift (self , periods , freq = None , ** kwds ):
2240
2240
"""
2241
2241
Shift the index of the Series by desired number of periods with an
2242
2242
optional time offset
@@ -2245,7 +2245,7 @@ def shift(self, periods, offset=None, **kwds):
2245
2245
----------
2246
2246
periods : int
2247
2247
Number of periods to move, can be positive or negative
2248
- offset : DateOffset, timedelta, or time rule string, optional
2248
+ freq : DateOffset, timedelta, or time rule string, optional
2249
2249
Increment to use from datetools module or time rule (e.g. 'EOM')
2250
2250
2251
2251
Returns
@@ -2255,13 +2255,23 @@ def shift(self, periods, offset=None, **kwds):
2255
2255
if periods == 0 :
2256
2256
return self .copy ()
2257
2257
2258
- offset = kwds . get ( 'timeRule' , offset )
2259
- if isinstance ( offset , basestring ):
2260
- # deprecated code path
2261
- if isinstance (self . index , DateRange ):
2258
+ if 'timeRule' in kwds or ' offset' in kwds :
2259
+ offset = kwds . get ( 'offset' )
2260
+ offset = kwds . get ( 'timeRule' , offset )
2261
+ if isinstance (offset , basestring ):
2262
2262
offset = datetools .getOffset (offset )
2263
- else :
2264
- offset = datetools .to_offset (offset )
2263
+ warn = True
2264
+ else :
2265
+ offset = freq
2266
+ warn = False
2267
+
2268
+ if warn :
2269
+ import warnings
2270
+ warnings .warn ("'timeRule' and 'offset' parameters are deprecated,"
2271
+ " please use 'freq' instead" , FutureWarning )
2272
+
2273
+ if isinstance (offset , basestring ):
2274
+ offset = datetools .to_offset (offset )
2265
2275
2266
2276
if offset is None :
2267
2277
new_values = np .empty (len (self ), dtype = self .dtype )
@@ -2326,7 +2336,7 @@ def asfreq(self, freq, method=None):
2326
2336
2327
2337
Parameters
2328
2338
----------
2329
- offset : DateOffset object, or corresponding string
2339
+ freq : DateOffset object, or corresponding string
2330
2340
DateOffset object or subclass (e.g. monthEnd)
2331
2341
method : {'backfill', 'pad', None}
2332
2342
Method to use for filling holes in new index
@@ -2336,8 +2346,6 @@ def asfreq(self, freq, method=None):
2336
2346
converted : TimeSeries
2337
2347
"""
2338
2348
2339
- # TODO: this uses deprecated API, add new method?
2340
-
2341
2349
if isinstance (freq , datetools .DateOffset ):
2342
2350
dateRange = DateRange (self .index [0 ], self .index [- 1 ], offset = freq )
2343
2351
else :
0 commit comments