Skip to content

Commit 6aeb19a

Browse files
committed
add year and nanosecond
1 parent 078e11f commit 6aeb19a

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
128128
-i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \
129129
-i "pandas.Timestamp.max PR02" \
130130
-i "pandas.Timestamp.min PR02" \
131-
-i "pandas.Timestamp.nanosecond GL08" \
132131
-i "pandas.Timestamp.resolution PR02" \
133132
-i "pandas.Timestamp.tzinfo GL08" \
134133
-i "pandas.Timestamp.value GL08" \
135-
-i "pandas.Timestamp.year GL08" \
136134
-i "pandas.api.extensions.ExtensionArray.interpolate PR01,SA01" \
137135
-i "pandas.api.interchange.from_dataframe RT03,SA01" \
138136
-i "pandas.api.types.is_bool PR01,SA01" \

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,29 @@ cdef class _Timestamp(ABCTimestamp):
10081008
"""
10091009
return super().fold
10101010
1011+
@property
1012+
def year(self) -> int:
1013+
"""
1014+
Return the year of the Timestamp.
1015+
1016+
Returns
1017+
-------
1018+
int
1019+
The year of the Timestamp.
1020+
1021+
See Also
1022+
--------
1023+
Timestamp.month : Return the month of the Timestamp.
1024+
Timestamp.day : Return the day of the Timestamp.
1025+
1026+
Examples
1027+
--------
1028+
>>> ts = pd.Timestamp("2024-08-31 16:16:30")
1029+
>>> ts.year
1030+
2024
1031+
"""
1032+
return super().year
1033+
10111034
@property
10121035
def month(self) -> int:
10131036
"""
@@ -1020,8 +1043,8 @@ cdef class _Timestamp(ABCTimestamp):
10201043

10211044
See Also
10221045
--------
1023-
Timestamp.day : Return the day of the year.
1024-
Timestamp.year : Return the year of the week.
1046+
Timestamp.day : Return the day of the Timestamp.
1047+
Timestamp.year : Return the year of the Timestamp.
10251048

10261049
Examples
10271050
--------
@@ -1123,6 +1146,29 @@ cdef class _Timestamp(ABCTimestamp):
11231146
"""
11241147
return super().microsecond
11251148
1149+
@property
1150+
def nanosecond(self) -> int:
1151+
"""
1152+
Return the nanosecond of the Timestamp.
1153+
1154+
Returns
1155+
-------
1156+
int
1157+
The nanosecond of the Timestamp.
1158+
1159+
See Also
1160+
--------
1161+
Timestamp.second : Return the second of the Timestamp.
1162+
Timestamp.microsecond : Return the microsecond of the Timestamp.
1163+
1164+
Examples
1165+
--------
1166+
>>> ts = pd.Timestamp("2024-08-31 16:16:30.230400015")
1167+
>>> ts.nanosecond
1168+
15
1169+
"""
1170+
return super().nanosecond
1171+
11261172
@property
11271173
def week(self) -> int:
11281174
"""

0 commit comments

Comments
 (0)