Skip to content

Commit 9d87c08

Browse files
authored
CLN: Timestamp unused attrs (#34216)
1 parent 9954f9e commit 9d87c08

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

pandas/_libs/tslibs/timestamps.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cdef class _Timestamp(ABCTimestamp):
1515
cdef readonly:
1616
int64_t value, nanosecond
1717
object freq
18-
list _date_attributes
18+
1919
cpdef bint _get_start_end_field(self, str field)
2020
cpdef _get_date_name_field(self, object field, object locale)
2121
cdef int64_t _maybe_convert_value_to_local(self)

pandas/_libs/tslibs/timestamps.pyx

+8-18
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ cdef class _Timestamp(ABCTimestamp):
387387
dtype=object,
388388
)
389389

390+
elif not isinstance(self, _Timestamp):
391+
# cython semantics, args have been switched and this is __radd__
392+
return other.__add__(self)
393+
390394
return NotImplemented
391395

392396
def __sub__(self, other):
@@ -1051,7 +1055,7 @@ timedelta}, default 'raise'
10511055
return Period(self, freq=freq)
10521056

10531057
@property
1054-
def dayofweek(self):
1058+
def dayofweek(self) -> int:
10551059
"""
10561060
Return day of the week.
10571061
"""
@@ -1092,7 +1096,7 @@ timedelta}, default 'raise'
10921096
return self._get_date_name_field('month_name', locale)
10931097

10941098
@property
1095-
def dayofyear(self):
1099+
def dayofyear(self) -> int:
10961100
"""
10971101
Return the day of the year.
10981102
"""
@@ -1115,7 +1119,7 @@ timedelta}, default 'raise'
11151119
return ((self.month - 1) // 3) + 1
11161120

11171121
@property
1118-
def days_in_month(self):
1122+
def days_in_month(self) -> int:
11191123
"""
11201124
Return the number of days in the month.
11211125
"""
@@ -1428,16 +1432,7 @@ default 'raise'
14281432

14291433
return base1 + base2
14301434

1431-
def _has_time_component(self) -> bool:
1432-
"""
1433-
Returns if the Timestamp has a time component
1434-
in addition to the date part
1435-
"""
1436-
return (self.time() != _zero_time
1437-
or self.tzinfo is not None
1438-
or self.nanosecond != 0)
1439-
1440-
def to_julian_date(self):
1435+
def to_julian_date(self) -> np.float64:
14411436
"""
14421437
Convert TimeStamp to a Julian Date.
14431438
0 Julian date is noon January 1, 4713 BC.
@@ -1474,11 +1469,6 @@ default 'raise'
14741469
np.array([self.value], dtype='i8'), tz=self.tz)[0]
14751470
return Timestamp(normalized_value).tz_localize(self.tz)
14761471

1477-
def __radd__(self, other):
1478-
# __radd__ on cython extension types like _Timestamp is not used, so
1479-
# define it here instead
1480-
return self + other
1481-
14821472

14831473
# Add the min and max fields at the class level
14841474
cdef int64_t _NS_UPPER_BOUND = np.iinfo(np.int64).max

0 commit comments

Comments
 (0)