Skip to content

Commit fb95f7f

Browse files
gfyoungjreback
authored andcommitted
CLN: Remove Timestamp.offset (#18927)
Deprecated in v0.19.0 xref gh-13593
1 parent aa84e00 commit fb95f7f

File tree

5 files changed

+9
-57
lines changed

5 files changed

+9
-57
lines changed

Diff for: doc/source/whatsnew/v0.23.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ Removal of prior version deprecations/changes
240240
- :func:`read_csv` has dropped the ``as_recarray`` parameter (:issue:`13373`)
241241
- :func:`read_csv` has dropped the ``buffer_lines`` parameter (:issue:`13360`)
242242
- :func:`read_csv` has dropped the ``compact_ints`` and ``use_unsigned`` parameters (:issue:`13323`)
243+
- The ``Timestamp`` class has dropped the ``offset`` attribute in favor of ``freq`` (:issue:`13593`)
243244

244245
.. _whatsnew_0230.performance:
245246

Diff for: pandas/_libs/tslibs/nattype.pyx

+1-3
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class NaTType(_NaT):
396396
""")
397397
fromordinal = _make_error_func('fromordinal', # noqa:E128
398398
"""
399-
Timestamp.fromordinal(ordinal, freq=None, tz=None, offset=None)
399+
Timestamp.fromordinal(ordinal, freq=None, tz=None)
400400
401401
passed an ordinal, translate and convert to a ts
402402
note: by definition there cannot be any tz info on the ordinal itself
@@ -409,8 +409,6 @@ class NaTType(_NaT):
409409
Offset which Timestamp will have
410410
tz : str, pytz.timezone, dateutil.tz.tzfile or None
411411
Time zone for time which Timestamp will have.
412-
offset : str, DateOffset
413-
Deprecated, use freq
414412
""")
415413

416414
# _nat_methods

Diff for: pandas/_libs/tslibs/timestamps.pyx

+4-22
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ class Timestamp(_Timestamp):
435435
"""
436436

437437
@classmethod
438-
def fromordinal(cls, ordinal, freq=None, tz=None, offset=None):
438+
def fromordinal(cls, ordinal, freq=None, tz=None):
439439
"""
440-
Timestamp.fromordinal(ordinal, freq=None, tz=None, offset=None)
440+
Timestamp.fromordinal(ordinal, freq=None, tz=None)
441441
442442
passed an ordinal, translate and convert to a ts
443443
note: by definition there cannot be any tz info on the ordinal itself
@@ -450,11 +450,9 @@ class Timestamp(_Timestamp):
450450
Offset which Timestamp will have
451451
tz : str, pytz.timezone, dateutil.tz.tzfile or None
452452
Time zone for time which Timestamp will have.
453-
offset : str, DateOffset
454-
Deprecated, use freq
455453
"""
456454
return cls(datetime.fromordinal(ordinal),
457-
freq=freq, tz=tz, offset=offset)
455+
freq=freq, tz=tz)
458456

459457
@classmethod
460458
def now(cls, tz=None):
@@ -529,8 +527,7 @@ class Timestamp(_Timestamp):
529527
object freq=None, tz=None, unit=None,
530528
year=None, month=None, day=None,
531529
hour=None, minute=None, second=None, microsecond=None,
532-
tzinfo=None,
533-
object offset=None):
530+
tzinfo=None):
534531
# The parameter list folds together legacy parameter names (the first
535532
# four) and positional and keyword parameter names from pydatetime.
536533
#
@@ -554,15 +551,6 @@ class Timestamp(_Timestamp):
554551

555552
cdef _TSObject ts
556553

557-
if offset is not None:
558-
# deprecate offset kwd in 0.19.0, GH13593
559-
if freq is not None:
560-
msg = "Can only specify freq or offset, not both"
561-
raise TypeError(msg)
562-
warnings.warn("offset is deprecated. Use freq instead",
563-
FutureWarning)
564-
freq = offset
565-
566554
if tzinfo is not None:
567555
if not PyTZInfo_Check(tzinfo):
568556
# tzinfo must be a datetime.tzinfo object, GH#17690
@@ -676,12 +664,6 @@ class Timestamp(_Timestamp):
676664
"""
677665
return self.tzinfo
678666

679-
@property
680-
def offset(self):
681-
warnings.warn(".offset is deprecated. Use .freq instead",
682-
FutureWarning)
683-
return self.freq
684-
685667
def __setstate__(self, state):
686668
self.value = state[0]
687669
self.freq = state[1]

Diff for: pandas/tests/scalar/test_nat.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ def test_NaT_docstrings():
170170
ts_missing = [x for x in ts_names if x not in nat_names and
171171
not x.startswith('_')]
172172
ts_missing.sort()
173-
ts_expected = ['freqstr', 'normalize', 'offset',
174-
'to_julian_date', 'to_period', 'tz']
173+
ts_expected = ['freqstr', 'normalize',
174+
'to_julian_date',
175+
'to_period', 'tz']
175176
assert ts_missing == ts_expected
176177

177178
ts_overlap = [x for x in nat_names if x in ts_names and

Diff for: pandas/tests/scalar/test_timestamp.py

-30
Original file line numberDiff line numberDiff line change
@@ -307,36 +307,6 @@ def test_constructor_fromordinal(self):
307307
ts = Timestamp.fromordinal(dt_tz.toordinal(), tz='US/Eastern')
308308
assert ts.to_pydatetime() == dt_tz
309309

310-
def test_constructor_offset_depr(self):
311-
# see gh-12160
312-
with tm.assert_produces_warning(FutureWarning,
313-
check_stacklevel=False):
314-
ts = Timestamp('2011-01-01', offset='D')
315-
assert ts.freq == 'D'
316-
317-
with tm.assert_produces_warning(FutureWarning,
318-
check_stacklevel=False):
319-
assert ts.offset == 'D'
320-
321-
msg = "Can only specify freq or offset, not both"
322-
with tm.assert_raises_regex(TypeError, msg):
323-
Timestamp('2011-01-01', offset='D', freq='D')
324-
325-
def test_constructor_offset_depr_fromordinal(self):
326-
# GH 12160
327-
base = datetime(2000, 1, 1)
328-
329-
with tm.assert_produces_warning(FutureWarning,
330-
check_stacklevel=False):
331-
ts = Timestamp.fromordinal(base.toordinal(), offset='D')
332-
assert Timestamp('2000-01-01') == ts
333-
assert ts.freq == 'D'
334-
assert base.toordinal() == ts.toordinal()
335-
336-
msg = "Can only specify freq or offset, not both"
337-
with tm.assert_raises_regex(TypeError, msg):
338-
Timestamp.fromordinal(base.toordinal(), offset='D', freq='D')
339-
340310

341311
class TestTimestamp(object):
342312

0 commit comments

Comments
 (0)