diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 8f4e719ad7cd6..b242b79dc7c66 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -290,7 +290,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Timestamp.quarter SA01" \ -i "pandas.Timestamp.replace PR07,SA01" \ -i "pandas.Timestamp.resolution PR02,PR07,SA01" \ - -i "pandas.Timestamp.round SA01" \ -i "pandas.Timestamp.second GL08" \ -i "pandas.Timestamp.strptime PR01,SA01" \ -i "pandas.Timestamp.time SA01" \ diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index cf7c20d84c2d4..0e1e0873a09b4 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -947,6 +947,12 @@ class NaTType(_NaT): """ Round the Timestamp to the specified resolution. + This method rounds the given Timestamp down to a specified frequency + level. It is particularly useful in data analysis to normalize timestamps + to regular frequency intervals. For instance, rounding to the nearest + minute, hour, or day can help in time series comparisons or resampling + operations. + Parameters ---------- freq : str @@ -981,6 +987,14 @@ timedelta}, default 'raise' ------ ValueError if the freq cannot be converted + See Also + -------- + datetime.round : Similar behavior in native Python datetime module. + Timestamp.floor : Round the Timestamp downward to the nearest multiple + of the specified frequency. + Timestamp.ceil : Round the Timestamp upward to the nearest multiple of + the specified frequency. + Notes ----- If the Timestamp has a timezone, rounding will take place relative to the diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index bcd758b9a9042..acde61b07c17e 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -2015,6 +2015,12 @@ class Timestamp(_Timestamp): """ Round the Timestamp to the specified resolution. + This method rounds the given Timestamp down to a specified frequency + level. It is particularly useful in data analysis to normalize timestamps + to regular frequency intervals. For instance, rounding to the nearest + minute, hour, or day can help in time series comparisons or resampling + operations. + Parameters ---------- freq : str @@ -2049,6 +2055,14 @@ timedelta}, default 'raise' ------ ValueError if the freq cannot be converted + See Also + -------- + datetime.round : Similar behavior in native Python datetime module. + Timestamp.floor : Round the Timestamp downward to the nearest multiple + of the specified frequency. + Timestamp.ceil : Round the Timestamp upward to the nearest multiple of + the specified frequency. + Notes ----- If the Timestamp has a timezone, rounding will take place relative to the