Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Timestamp.month GL08" \
-i "pandas.Timestamp.month_name SA01" \
-i "pandas.Timestamp.nanosecond GL08" \
-i "pandas.Timestamp.normalize SA01" \
-i "pandas.Timestamp.quarter SA01" \
-i "pandas.Timestamp.replace PR07,SA01" \
-i "pandas.Timestamp.resolution PR02" \
-i "pandas.Timestamp.second GL08" \
-i "pandas.Timestamp.strptime PR01,SA01" \
Expand All @@ -229,8 +227,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Timestamp.timetz SA01" \
-i "pandas.Timestamp.to_datetime64 SA01" \
-i "pandas.Timestamp.to_julian_date SA01" \
-i "pandas.Timestamp.to_numpy PR01" \
-i "pandas.Timestamp.to_period PR01,SA01" \
-i "pandas.Timestamp.today SA01" \
-i "pandas.Timestamp.toordinal SA01" \
-i "pandas.Timestamp.tz_localize SA01" \
Expand Down
55 changes: 53 additions & 2 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,13 @@ cdef class _Timestamp(ABCTimestamp):

def normalize(self) -> "Timestamp":
"""
Normalize Timestamp to midnight, preserving tz information.
Normalize Timestamp to previous midnight, preserving tz information.

This is equivalent to replacing the time part of the timestamp with `00:00:00`.

See Also
--------
Timestamp.replace : Return a new timestamp with replaced attributes.

Examples
--------
Expand Down Expand Up @@ -1276,6 +1282,13 @@ cdef class _Timestamp(ABCTimestamp):
copy parameters are available here only for compatibility. Their values
will not affect the return value.

Parameters
----------
dtype : numpy.dtype, default None
Must be None. Otherwise, a ValueError is raised.
copy : bool, default False
Must be False. Otherwise, a ValueError is raised.

Returns
-------
numpy.datetime64
Expand Down Expand Up @@ -1303,7 +1316,24 @@ cdef class _Timestamp(ABCTimestamp):

def to_period(self, freq=None):
"""
Return an period of which this timestamp is an observation.
Return a period of which this timestamp is an observation.

This method constructs a `Period` object from the `Timestamp`
and provided period.
Please note that timezone information will be dropped,
since `Period` doesn't support timezones.

Parameters
----------
freq : str, default None
The period frequency. Accepted strings are listed in
the :ref:`period alias section <timeseries.period_aliases>`
in the user docs.

See Also
--------
Period : Represents a period of time.
Period.to_timestamp : Return the Timestamp representation of the Period.

Examples
--------
Expand Down Expand Up @@ -2603,23 +2633,44 @@ default 'raise'
"""
Implements datetime.replace, handles nanoseconds.

Returns a new timestamp with the same attributes,
except for those given new value.

Parameters
----------
year : int, optional
New year value.
month : int, optional
New month value.
day : int, optional
New day value.
hour : int, optional
New hour value.
minute : int, optional
New minute value.
second : int, optional
New second value.
microsecond : int, optional
New microsecond value.
nanosecond : int, optional
New nanosecond value.
tzinfo : tz-convertible, optional
New tzinfo value.
fold : int, optional
New fold value.

Returns
-------
Timestamp with fields replaced

See Also
--------
Timestamp.normalize : Normalize the Timestamp to midnight,
preserving tz information.
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
Timestamp.tz_localize : Localize the Timestamp to a timezone.
datetime.datetime.replace : Return a new datetime with replaced attributes.

Examples
--------
Create a timestamp object:
Expand Down