Skip to content

Commit ac39473

Browse files
Josiah BakerWillAyd
Josiah Baker
authored andcommitted
DOC: fix PR09,PR08 errors for pandas.Timestamp (#28739)
1 parent 069e124 commit ac39473

File tree

3 files changed

+201
-160
lines changed

3 files changed

+201
-160
lines changed

pandas/_libs/tslibs/nattype.pyx

+91-75
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class NaTType(_NaT):
396396
Parameters
397397
----------
398398
locale : string, default None (English locale)
399-
locale determining the language in which to return the month name
399+
Locale determining the language in which to return the month name.
400400
401401
Returns
402402
-------
@@ -411,7 +411,7 @@ class NaTType(_NaT):
411411
Parameters
412412
----------
413413
locale : string, default None (English locale)
414-
locale determining the language in which to return the day name
414+
Locale determining the language in which to return the day name.
415415
416416
Returns
417417
-------
@@ -509,11 +509,11 @@ class NaTType(_NaT):
509509
Parameters
510510
----------
511511
ordinal : int
512-
date corresponding to a proleptic Gregorian ordinal
512+
Date corresponding to a proleptic Gregorian ordinal.
513513
freq : str, DateOffset
514-
Offset which Timestamp will have
514+
Offset to apply to the Timestamp.
515515
tz : str, pytz.timezone, dateutil.tz.tzfile or None
516-
Time zone for time which Timestamp will have.
516+
Time zone for the Timestamp.
517517
""")
518518

519519
# _nat_methods
@@ -534,7 +534,7 @@ class NaTType(_NaT):
534534
Parameters
535535
----------
536536
tz : str or timezone object, default None
537-
Timezone to localize to
537+
Timezone to localize to.
538538
""")
539539
today = _make_nat_func('today', # noqa:E128
540540
"""
@@ -547,35 +547,38 @@ class NaTType(_NaT):
547547
Parameters
548548
----------
549549
tz : str or timezone object, default None
550-
Timezone to localize to
550+
Timezone to localize to.
551551
""")
552552
round = _make_nat_func('round', # noqa:E128
553553
"""
554554
Round the Timestamp to the specified resolution.
555555
556556
Parameters
557557
----------
558-
freq : a freq string indicating the rounding resolution
559-
ambiguous : bool, 'NaT', default 'raise'
560-
- bool contains flags to determine if time is dst or not (note
561-
that this flag is only applicable for ambiguous fall dst dates)
562-
- 'NaT' will return NaT for an ambiguous time
563-
- 'raise' will raise an AmbiguousTimeError for an ambiguous time
558+
freq : str
559+
Frequency string indicating the rounding resolution.
560+
ambiguous : bool or {'raise', 'NaT'}, default 'raise'
561+
The behavior is as follows:
562+
563+
* bool contains flags to determine if time is dst or not (note
564+
that this flag is only applicable for ambiguous fall dst dates).
565+
* 'NaT' will return NaT for an ambiguous time.
566+
* 'raise' will raise an AmbiguousTimeError for an ambiguous time.
564567
565568
.. versionadded:: 0.24.0
566-
nonexistent : 'shift_forward', 'shift_backward, 'NaT', timedelta, \
567-
default 'raise'
569+
nonexistent : {'raise', 'shift_forward', 'shift_backward, 'NaT', \
570+
timedelta}, default 'raise'
568571
A nonexistent time does not exist in a particular timezone
569572
where clocks moved forward due to DST.
570573
571-
- 'shift_forward' will shift the nonexistent time forward to the
572-
closest existing time
573-
- 'shift_backward' will shift the nonexistent time backward to the
574-
closest existing time
575-
- 'NaT' will return NaT where there are nonexistent times
576-
- timedelta objects will shift nonexistent times by the timedelta
577-
- 'raise' will raise an NonExistentTimeError if there are
578-
nonexistent times
574+
* 'shift_forward' will shift the nonexistent time forward to the
575+
closest existing time.
576+
* 'shift_backward' will shift the nonexistent time backward to the
577+
closest existing time.
578+
* 'NaT' will return NaT where there are nonexistent times.
579+
* timedelta objects will shift nonexistent times by the timedelta.
580+
* 'raise' will raise an NonExistentTimeError if there are
581+
nonexistent times.
579582
580583
.. versionadded:: 0.24.0
581584
@@ -593,67 +596,73 @@ default 'raise'
593596
594597
Parameters
595598
----------
596-
freq : a freq string indicating the flooring resolution
597-
ambiguous : bool, 'NaT', default 'raise'
598-
- bool contains flags to determine if time is dst or not (note
599-
that this flag is only applicable for ambiguous fall dst dates)
600-
- 'NaT' will return NaT for an ambiguous time
601-
- 'raise' will raise an AmbiguousTimeError for an ambiguous time
599+
freq : str
600+
Frequency string indicating the flooring resolution.
601+
ambiguous : bool or {'raise', 'NaT'}, default 'raise'
602+
The behavior is as follows:
603+
604+
* bool contains flags to determine if time is dst or not (note
605+
that this flag is only applicable for ambiguous fall dst dates).
606+
* 'NaT' will return NaT for an ambiguous time.
607+
* 'raise' will raise an AmbiguousTimeError for an ambiguous time.
602608
603609
.. versionadded:: 0.24.0
604-
nonexistent : 'shift_forward', 'shift_backward, 'NaT', timedelta, \
605-
default 'raise'
610+
nonexistent : {'raise', 'shift_forward', 'shift_backward, 'NaT', \
611+
timedelta}, default 'raise'
606612
A nonexistent time does not exist in a particular timezone
607613
where clocks moved forward due to DST.
608614
609-
- 'shift_forward' will shift the nonexistent time forward to the
610-
closest existing time
611-
- 'shift_backward' will shift the nonexistent time backward to the
612-
closest existing time
613-
- 'NaT' will return NaT where there are nonexistent times
614-
- timedelta objects will shift nonexistent times by the timedelta
615-
- 'raise' will raise an NonExistentTimeError if there are
616-
nonexistent times
615+
* 'shift_forward' will shift the nonexistent time forward to the
616+
closest existing time.
617+
* 'shift_backward' will shift the nonexistent time backward to the
618+
closest existing time.
619+
* 'NaT' will return NaT where there are nonexistent times.
620+
* timedelta objects will shift nonexistent times by the timedelta.
621+
* 'raise' will raise an NonExistentTimeError if there are
622+
nonexistent times.
617623
618624
.. versionadded:: 0.24.0
619625
620626
Raises
621627
------
622-
ValueError if the freq cannot be converted
628+
ValueError if the freq cannot be converted.
623629
""")
624630
ceil = _make_nat_func('ceil', # noqa:E128
625631
"""
626632
return a new Timestamp ceiled to this resolution.
627633
628634
Parameters
629635
----------
630-
freq : a freq string indicating the ceiling resolution
631-
ambiguous : bool, 'NaT', default 'raise'
632-
- bool contains flags to determine if time is dst or not (note
633-
that this flag is only applicable for ambiguous fall dst dates)
634-
- 'NaT' will return NaT for an ambiguous time
635-
- 'raise' will raise an AmbiguousTimeError for an ambiguous time
636+
freq : str
637+
Frequency string indicating the ceiling resolution.
638+
ambiguous : bool or {'raise', 'NaT'}, default 'raise'
639+
The behavior is as follows:
640+
641+
* bool contains flags to determine if time is dst or not (note
642+
that this flag is only applicable for ambiguous fall dst dates).
643+
* 'NaT' will return NaT for an ambiguous time.
644+
* 'raise' will raise an AmbiguousTimeError for an ambiguous time.
636645
637646
.. versionadded:: 0.24.0
638-
nonexistent : 'shift_forward', 'shift_backward, 'NaT', timedelta, \
639-
default 'raise'
647+
nonexistent : {'raise', 'shift_forward', 'shift_backward, 'NaT', \
648+
timedelta}, default 'raise'
640649
A nonexistent time does not exist in a particular timezone
641650
where clocks moved forward due to DST.
642651
643-
- 'shift_forward' will shift the nonexistent time forward to the
644-
closest existing time
645-
- 'shift_backward' will shift the nonexistent time backward to the
646-
closest existing time
647-
- 'NaT' will return NaT where there are nonexistent times
648-
- timedelta objects will shift nonexistent times by the timedelta
649-
- 'raise' will raise an NonExistentTimeError if there are
650-
nonexistent times
652+
* 'shift_forward' will shift the nonexistent time forward to the
653+
closest existing time.
654+
* 'shift_backward' will shift the nonexistent time backward to the
655+
closest existing time.
656+
* 'NaT' will return NaT where there are nonexistent times.
657+
* timedelta objects will shift nonexistent times by the timedelta.
658+
* 'raise' will raise an NonExistentTimeError if there are
659+
nonexistent times.
651660
652661
.. versionadded:: 0.24.0
653662
654663
Raises
655664
------
656-
ValueError if the freq cannot be converted
665+
ValueError if the freq cannot be converted.
657666
""")
658667

659668
tz_convert = _make_nat_func('tz_convert', # noqa:E128
@@ -694,35 +703,42 @@ default 'raise'
694703
`ambiguous` parameter dictates how ambiguous times should be
695704
handled.
696705
697-
- bool contains flags to determine if time is dst or not (note
698-
that this flag is only applicable for ambiguous fall dst dates)
699-
- 'NaT' will return NaT for an ambiguous time
700-
- 'raise' will raise an AmbiguousTimeError for an ambiguous time
706+
The behavior is as follows:
707+
708+
* bool contains flags to determine if time is dst or not (note
709+
that this flag is only applicable for ambiguous fall dst dates).
710+
* 'NaT' will return NaT for an ambiguous time.
711+
* 'raise' will raise an AmbiguousTimeError for an ambiguous time.
701712
702713
nonexistent : 'shift_forward', 'shift_backward, 'NaT', timedelta, \
703714
default 'raise'
704715
A nonexistent time does not exist in a particular timezone
705716
where clocks moved forward due to DST.
706717
707-
- 'shift_forward' will shift the nonexistent time forward to the
708-
closest existing time
709-
- 'shift_backward' will shift the nonexistent time backward to the
710-
closest existing time
711-
- 'NaT' will return NaT where there are nonexistent times
712-
- timedelta objects will shift nonexistent times by the timedelta
713-
- 'raise' will raise an NonExistentTimeError if there are
714-
nonexistent times
718+
The behavior is as follows:
715719
716-
.. versionadded:: 0.24.0
720+
* 'shift_forward' will shift the nonexistent time forward to the
721+
closest existing time.
722+
* 'shift_backward' will shift the nonexistent time backward to the
723+
closest existing time.
724+
* 'NaT' will return NaT where there are nonexistent times.
725+
* timedelta objects will shift nonexistent times by the timedelta.
726+
* 'raise' will raise an NonExistentTimeError if there are
727+
nonexistent times.
717728
729+
.. versionadded:: 0.24.0
718730
errors : 'raise', 'coerce', default None
719-
- 'raise' will raise a NonExistentTimeError if a timestamp is not
720-
valid in the specified timezone (e.g. due to a transition from
721-
or to DST time). Use ``nonexistent='raise'`` instead.
722-
- 'coerce' will return NaT if the timestamp can not be converted
731+
Determine how errors should be handled.
732+
733+
The behavior is as follows:
734+
735+
* 'raise' will raise a NonExistentTimeError if a timestamp is not
736+
valid in the specified timezone (e.g. due to a transition from
737+
or to DST time). Use ``nonexistent='raise'`` instead.
738+
* 'coerce' will return NaT if the timestamp can not be converted
723739
into the specified timezone. Use ``nonexistent='NaT'`` instead.
724740
725-
.. deprecated:: 0.24.0
741+
.. deprecated:: 0.24.0
726742
727743
Returns
728744
-------

pandas/_libs/tslibs/timedeltas.pyx

+19-10
Original file line numberDiff line numberDiff line change
@@ -1215,14 +1215,20 @@ class Timedelta(_Timedelta):
12151215
Parameters
12161216
----------
12171217
value : Timedelta, timedelta, np.timedelta64, string, or integer
1218-
unit : str, optional
1219-
Denote the unit of the input, if input is an integer. Default 'ns'.
1218+
unit : str, default 'ns'
1219+
Denote the unit of the input, if input is an integer.
1220+
12201221
Possible values:
1221-
{'Y', 'M', 'W', 'D', 'days', 'day', 'hours', hour', 'hr', 'h',
1222-
'm', 'minute', 'min', 'minutes', 'T', 'S', 'seconds', 'sec', 'second',
1223-
'ms', 'milliseconds', 'millisecond', 'milli', 'millis', 'L',
1224-
'us', 'microseconds', 'microsecond', 'micro', 'micros', 'U',
1225-
'ns', 'nanoseconds', 'nano', 'nanos', 'nanosecond', 'N'}
1222+
1223+
* 'Y', 'M', 'W', 'D', 'T', 'S', 'L', 'U', or 'N'
1224+
* 'days' or 'day'
1225+
* 'hours', 'hour', 'hr', or 'h'
1226+
* 'minutes', 'minute', 'min', or 'm'
1227+
* 'seconds', 'second', or 'sec'
1228+
* 'milliseconds', 'millisecond', 'millis', or 'milli'
1229+
* 'microseconds', 'microsecond', 'micros', or 'micro'
1230+
* 'nanoseconds', 'nanosecond', 'nanos', 'nano', or 'ns'.
1231+
12261232
**kwargs
12271233
Available kwargs: {days, seconds, microseconds,
12281234
milliseconds, minutes, hours, weeks}.
@@ -1323,7 +1329,8 @@ class Timedelta(_Timedelta):
13231329
13241330
Parameters
13251331
----------
1326-
freq : a freq string indicating the rounding resolution
1332+
freq : str
1333+
Frequency string indicating the rounding resolution.
13271334
13281335
Returns
13291336
-------
@@ -1341,7 +1348,8 @@ class Timedelta(_Timedelta):
13411348
13421349
Parameters
13431350
----------
1344-
freq : a freq string indicating the flooring resolution
1351+
freq : str
1352+
Frequency string indicating the flooring resolution.
13451353
"""
13461354
return self._round(freq, np.floor)
13471355

@@ -1351,7 +1359,8 @@ class Timedelta(_Timedelta):
13511359
13521360
Parameters
13531361
----------
1354-
freq : a freq string indicating the ceiling resolution
1362+
freq : str
1363+
Frequency string indicating the ceiling resolution.
13551364
"""
13561365
return self._round(freq, np.ceil)
13571366

0 commit comments

Comments
 (0)