Skip to content

DOC: fix PR09,PR08 errors for pandas.Timestamp #28739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
166 changes: 91 additions & 75 deletions pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class NaTType(_NaT):
Parameters
----------
locale : string, default None (English locale)
locale determining the language in which to return the month name
Locale determining the language in which to return the month name.
Returns
-------
Expand All @@ -411,7 +411,7 @@ class NaTType(_NaT):
Parameters
----------
locale : string, default None (English locale)
locale determining the language in which to return the day name
Locale determining the language in which to return the day name.
Returns
-------
Expand Down Expand Up @@ -509,11 +509,11 @@ class NaTType(_NaT):
Parameters
----------
ordinal : int
date corresponding to a proleptic Gregorian ordinal
Date corresponding to a proleptic Gregorian ordinal.
freq : str, DateOffset
Offset which Timestamp will have
Offset to apply to the Timestamp.
tz : str, pytz.timezone, dateutil.tz.tzfile or None
Time zone for time which Timestamp will have.
Time zone for the Timestamp.
""")

# _nat_methods
Expand All @@ -534,7 +534,7 @@ class NaTType(_NaT):
Parameters
----------
tz : str or timezone object, default None
Timezone to localize to
Timezone to localize to.
""")
today = _make_nat_func('today', # noqa:E128
"""
Expand All @@ -547,35 +547,38 @@ class NaTType(_NaT):
Parameters
----------
tz : str or timezone object, default None
Timezone to localize to
Timezone to localize to.
""")
round = _make_nat_func('round', # noqa:E128
"""
Round the Timestamp to the specified resolution.
Parameters
----------
freq : a freq string indicating the rounding resolution
ambiguous : bool, 'NaT', default 'raise'
- bool contains flags to determine if time is dst or not (note
that this flag is only applicable for ambiguous fall dst dates)
- 'NaT' will return NaT for an ambiguous time
- 'raise' will raise an AmbiguousTimeError for an ambiguous time
freq : str
Frequency string indicating the rounding resolution.
ambiguous : bool or {'raise', 'NaT'}, default 'raise'
The behavior is as follows:
* bool contains flags to determine if time is dst or not (note
that this flag is only applicable for ambiguous fall dst dates).
* 'NaT' will return NaT for an ambiguous time.
* 'raise' will raise an AmbiguousTimeError for an ambiguous time.
.. versionadded:: 0.24.0
nonexistent : 'shift_forward', 'shift_backward, 'NaT', timedelta, \
default 'raise'
nonexistent : {'raise', 'shift_forward', 'shift_backward, 'NaT', \
timedelta}, default 'raise'
A nonexistent time does not exist in a particular timezone
where clocks moved forward due to DST.
- 'shift_forward' will shift the nonexistent time forward to the
closest existing time
- 'shift_backward' will shift the nonexistent time backward to the
closest existing time
- 'NaT' will return NaT where there are nonexistent times
- timedelta objects will shift nonexistent times by the timedelta
- 'raise' will raise an NonExistentTimeError if there are
nonexistent times
* 'shift_forward' will shift the nonexistent time forward to the
closest existing time.
* 'shift_backward' will shift the nonexistent time backward to the
closest existing time.
* 'NaT' will return NaT where there are nonexistent times.
* timedelta objects will shift nonexistent times by the timedelta.
* 'raise' will raise an NonExistentTimeError if there are
nonexistent times.
.. versionadded:: 0.24.0
Expand All @@ -593,67 +596,73 @@ default 'raise'
Parameters
----------
freq : a freq string indicating the flooring resolution
ambiguous : bool, 'NaT', default 'raise'
- bool contains flags to determine if time is dst or not (note
that this flag is only applicable for ambiguous fall dst dates)
- 'NaT' will return NaT for an ambiguous time
- 'raise' will raise an AmbiguousTimeError for an ambiguous time
freq : str
Frequency string indicating the flooring resolution.
ambiguous : bool or {'raise', 'NaT'}, default 'raise'
The behavior is as follows:
* bool contains flags to determine if time is dst or not (note
that this flag is only applicable for ambiguous fall dst dates).
* 'NaT' will return NaT for an ambiguous time.
* 'raise' will raise an AmbiguousTimeError for an ambiguous time.
.. versionadded:: 0.24.0
nonexistent : 'shift_forward', 'shift_backward, 'NaT', timedelta, \
default 'raise'
nonexistent : {'raise', 'shift_forward', 'shift_backward, 'NaT', \
timedelta}, default 'raise'
A nonexistent time does not exist in a particular timezone
where clocks moved forward due to DST.
- 'shift_forward' will shift the nonexistent time forward to the
closest existing time
- 'shift_backward' will shift the nonexistent time backward to the
closest existing time
- 'NaT' will return NaT where there are nonexistent times
- timedelta objects will shift nonexistent times by the timedelta
- 'raise' will raise an NonExistentTimeError if there are
nonexistent times
* 'shift_forward' will shift the nonexistent time forward to the
closest existing time.
* 'shift_backward' will shift the nonexistent time backward to the
closest existing time.
* 'NaT' will return NaT where there are nonexistent times.
* timedelta objects will shift nonexistent times by the timedelta.
* 'raise' will raise an NonExistentTimeError if there are
nonexistent times.
.. versionadded:: 0.24.0
Raises
------
ValueError if the freq cannot be converted
ValueError if the freq cannot be converted.
""")
ceil = _make_nat_func('ceil', # noqa:E128
"""
return a new Timestamp ceiled to this resolution.
Parameters
----------
freq : a freq string indicating the ceiling resolution
ambiguous : bool, 'NaT', default 'raise'
- bool contains flags to determine if time is dst or not (note
that this flag is only applicable for ambiguous fall dst dates)
- 'NaT' will return NaT for an ambiguous time
- 'raise' will raise an AmbiguousTimeError for an ambiguous time
freq : str
Frequency string indicating the ceiling resolution.
ambiguous : bool or {'raise', 'NaT'}, default 'raise'
The behavior is as follows:
* bool contains flags to determine if time is dst or not (note
that this flag is only applicable for ambiguous fall dst dates).
* 'NaT' will return NaT for an ambiguous time.
* 'raise' will raise an AmbiguousTimeError for an ambiguous time.
.. versionadded:: 0.24.0
nonexistent : 'shift_forward', 'shift_backward, 'NaT', timedelta, \
default 'raise'
nonexistent : {'raise', 'shift_forward', 'shift_backward, 'NaT', \
timedelta}, default 'raise'
A nonexistent time does not exist in a particular timezone
where clocks moved forward due to DST.
- 'shift_forward' will shift the nonexistent time forward to the
closest existing time
- 'shift_backward' will shift the nonexistent time backward to the
closest existing time
- 'NaT' will return NaT where there are nonexistent times
- timedelta objects will shift nonexistent times by the timedelta
- 'raise' will raise an NonExistentTimeError if there are
nonexistent times
* 'shift_forward' will shift the nonexistent time forward to the
closest existing time.
* 'shift_backward' will shift the nonexistent time backward to the
closest existing time.
* 'NaT' will return NaT where there are nonexistent times.
* timedelta objects will shift nonexistent times by the timedelta.
* 'raise' will raise an NonExistentTimeError if there are
nonexistent times.
.. versionadded:: 0.24.0
Raises
------
ValueError if the freq cannot be converted
ValueError if the freq cannot be converted.
""")

tz_convert = _make_nat_func('tz_convert', # noqa:E128
Expand Down Expand Up @@ -694,35 +703,42 @@ default 'raise'
`ambiguous` parameter dictates how ambiguous times should be
handled.
- bool contains flags to determine if time is dst or not (note
that this flag is only applicable for ambiguous fall dst dates)
- 'NaT' will return NaT for an ambiguous time
- 'raise' will raise an AmbiguousTimeError for an ambiguous time
The behavior is as follows:
* bool contains flags to determine if time is dst or not (note
that this flag is only applicable for ambiguous fall dst dates).
* 'NaT' will return NaT for an ambiguous time.
* 'raise' will raise an AmbiguousTimeError for an ambiguous time.
nonexistent : 'shift_forward', 'shift_backward, 'NaT', timedelta, \
default 'raise'
A nonexistent time does not exist in a particular timezone
where clocks moved forward due to DST.
- 'shift_forward' will shift the nonexistent time forward to the
closest existing time
- 'shift_backward' will shift the nonexistent time backward to the
closest existing time
- 'NaT' will return NaT where there are nonexistent times
- timedelta objects will shift nonexistent times by the timedelta
- 'raise' will raise an NonExistentTimeError if there are
nonexistent times
The behavior is as follows:
.. versionadded:: 0.24.0
* 'shift_forward' will shift the nonexistent time forward to the
closest existing time.
* 'shift_backward' will shift the nonexistent time backward to the
closest existing time.
* 'NaT' will return NaT where there are nonexistent times.
* timedelta objects will shift nonexistent times by the timedelta.
* 'raise' will raise an NonExistentTimeError if there are
nonexistent times.
.. versionadded:: 0.24.0
errors : 'raise', 'coerce', default None
- 'raise' will raise a NonExistentTimeError if a timestamp is not
valid in the specified timezone (e.g. due to a transition from
or to DST time). Use ``nonexistent='raise'`` instead.
- 'coerce' will return NaT if the timestamp can not be converted
Determine how errors should be handled.
The behavior is as follows:
* 'raise' will raise a NonExistentTimeError if a timestamp is not
valid in the specified timezone (e.g. due to a transition from
or to DST time). Use ``nonexistent='raise'`` instead.
* 'coerce' will return NaT if the timestamp can not be converted
into the specified timezone. Use ``nonexistent='NaT'`` instead.
.. deprecated:: 0.24.0
.. deprecated:: 0.24.0
Returns
-------
Expand Down
29 changes: 19 additions & 10 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1215,14 +1215,20 @@ class Timedelta(_Timedelta):
Parameters
----------
value : Timedelta, timedelta, np.timedelta64, string, or integer
unit : str, optional
Denote the unit of the input, if input is an integer. Default 'ns'.
unit : str, default 'ns'
Denote the unit of the input, if input is an integer.
Possible values:
{'Y', 'M', 'W', 'D', 'days', 'day', 'hours', hour', 'hr', 'h',
'm', 'minute', 'min', 'minutes', 'T', 'S', 'seconds', 'sec', 'second',
'ms', 'milliseconds', 'millisecond', 'milli', 'millis', 'L',
'us', 'microseconds', 'microsecond', 'micro', 'micros', 'U',
'ns', 'nanoseconds', 'nano', 'nanos', 'nanosecond', 'N'}
* 'Y', 'M', 'W', 'D', 'T', 'S', 'L', 'U', or 'N'
* 'days' or 'day'
* 'hours', 'hour', 'hr', or 'h'
* 'minutes', 'minute', 'min', or 'm'
* 'seconds', 'second', or 'sec'
* 'milliseconds', 'millisecond', 'millis', or 'milli'
* 'microseconds', 'microsecond', 'micros', or 'micro'
* 'nanoseconds', 'nanosecond', 'nanos', 'nano', or 'ns'.
**kwargs
Available kwargs: {days, seconds, microseconds,
milliseconds, minutes, hours, weeks}.
Expand Down Expand Up @@ -1323,7 +1329,8 @@ class Timedelta(_Timedelta):
Parameters
----------
freq : a freq string indicating the rounding resolution
freq : str
Frequency string indicating the rounding resolution.
Returns
-------
Expand All @@ -1341,7 +1348,8 @@ class Timedelta(_Timedelta):
Parameters
----------
freq : a freq string indicating the flooring resolution
freq : str
Frequency string indicating the flooring resolution.
"""
return self._round(freq, np.floor)

Expand All @@ -1351,7 +1359,8 @@ class Timedelta(_Timedelta):
Parameters
----------
freq : a freq string indicating the ceiling resolution
freq : str
Frequency string indicating the ceiling resolution.
"""
return self._round(freq, np.ceil)

Expand Down
Loading