Skip to content

Commit 1d58928

Browse files
authored
DOC add examples to Timestamp.unit (#51091)
add examples to timestamp.unit Co-authored-by: MarcoGorelli <>
1 parent 4033156 commit 1d58928

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ci/code_checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
187187
pandas.show_versions \
188188
pandas.test \
189189
pandas.NaT \
190-
pandas.Timestamp.unit \
191190
pandas.Timestamp.as_unit \
192191
pandas.Timestamp.ctime \
193192
pandas.Timestamp.date \

pandas/_libs/tslibs/timestamps.pyx

+14
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,20 @@ cdef class _Timestamp(ABCTimestamp):
236236
def unit(self) -> str:
237237
"""
238238
The abbreviation associated with self._creso.
239+
240+
Examples
241+
--------
242+
>>> pd.Timestamp("2020-01-01 12:34:56").unit
243+
's'
244+
245+
>>> pd.Timestamp("2020-01-01 12:34:56.123").unit
246+
'ms'
247+
248+
>>> pd.Timestamp("2020-01-01 12:34:56.123456").unit
249+
'us'
250+
251+
>>> pd.Timestamp("2020-01-01 12:34:56.123456789").unit
252+
'ns'
239253
"""
240254
return npy_unit_to_abbrev(self._creso)
241255

0 commit comments

Comments
 (0)