Skip to content

Add ss02 #37559

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 10 commits into from
Nov 10, 2020
4 changes: 2 additions & 2 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ fi
### DOCSTRINGS ###
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then

MSG='Validate docstrings (GL03, GL04, GL05, GL06, GL07, GL09, GL10, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT01, RT04, RT05, SA02, SA03)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=GL03,GL04,GL05,GL06,GL07,GL09,GL10,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT01,RT04,RT05,SA02,SA03
MSG='Validate docstrings (GL03, GL04, GL05, GL06, GL07, GL09, GL10, SS02, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT01, RT04, RT05, SA02, SA03)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=GL03,GL04,GL05,GL06,GL07,GL09,GL10,SS02,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT01,RT04,RT05,SA02,SA03
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Validate correct capitalization among titles in documentation' ; echo $MSG
Expand Down
28 changes: 22 additions & 6 deletions pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ class NaTType(_NaT):
utctimetuple = _make_error_func("utctimetuple", datetime)
timetz = _make_error_func("timetz", datetime)
timetuple = _make_error_func("timetuple", datetime)
strftime = _make_error_func("strftime", datetime)
isocalendar = _make_error_func("isocalendar", datetime)
dst = _make_error_func("dst", datetime)
ctime = _make_error_func("ctime", datetime)
Expand All @@ -435,6 +434,23 @@ class NaTType(_NaT):
# The remaining methods have docstrings copy/pasted from the analogous
# Timestamp methods.

strftime = _make_error_func(
"strftime",
"""
Timestamp.strftime(format)

Return a string representing the given POSIX timestamp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the link

controlled by an explicit format string.

Parameters
----------
format : str
Format string to convert Timestamp to string.
See strftime documentation for more information on the format string:
https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior.
""",
)

strptime = _make_error_func(
"strptime",
"""
Expand All @@ -457,15 +473,15 @@ class NaTType(_NaT):
"""
Timestamp.fromtimestamp(ts)

timestamp[, tz] -> tz's local time from POSIX timestamp.
Transform timestamp[, tz] to tz's local time from POSIX timestamp.
""",
)
combine = _make_error_func(
"combine",
"""
Timestamp.combine(date, time)

date, time -> datetime with same date and time fields.
Combine date, time into datetime with same date and time fields.
""",
)
utcnow = _make_error_func(
Expand Down Expand Up @@ -606,7 +622,7 @@ timedelta}, default 'raise'
floor = _make_nat_func(
"floor",
"""
return a new Timestamp floored to this resolution.
Return a new Timestamp floored to this resolution.

Parameters
----------
Expand Down Expand Up @@ -645,7 +661,7 @@ timedelta}, default 'raise'
ceil = _make_nat_func(
"ceil",
"""
return a new Timestamp ceiled to this resolution.
Return a new Timestamp ceiled to this resolution.

Parameters
----------
Expand Down Expand Up @@ -761,7 +777,7 @@ default 'raise'
replace = _make_nat_func(
"replace",
"""
implements datetime.replace, handles nanoseconds.
Implements datetime.replace, handles nanoseconds.

Parameters
----------
Expand Down
26 changes: 21 additions & 5 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,26 @@ class Timestamp(_Timestamp):
"""
Timestamp.fromtimestamp(ts)

timestamp[, tz] -> tz's local time from POSIX timestamp.
Transform timestamp[, tz] to tz's local time from POSIX timestamp.
"""
return cls(datetime.fromtimestamp(ts))

def strftime(self, format):
"""
Timestamp.strftime(format)

Return a string representing the given POSIX timestamp
controlled by an explicit format string.

Parameters
----------
format : str
Format string to convert Timestamp to string.
See strftime documentation for more information on the format string:
https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior.
"""
return datetime.strftime(self, format)

# Issue 25016.
@classmethod
def strptime(cls, date_string, format):
Expand All @@ -934,7 +950,7 @@ class Timestamp(_Timestamp):
"""
Timestamp.combine(date, time)

date, time -> datetime with same date and time fields.
Combine date, time into datetime with same date and time fields.
"""
return cls(datetime.combine(date, time))

Expand Down Expand Up @@ -1153,7 +1169,7 @@ timedelta}, default 'raise'

def floor(self, freq, ambiguous='raise', nonexistent='raise'):
"""
return a new Timestamp floored to this resolution.
Return a new Timestamp floored to this resolution.

Parameters
----------
Expand Down Expand Up @@ -1192,7 +1208,7 @@ timedelta}, default 'raise'

def ceil(self, freq, ambiguous='raise', nonexistent='raise'):
"""
return a new Timestamp ceiled to this resolution.
Return a new Timestamp ceiled to this resolution.

Parameters
----------
Expand Down Expand Up @@ -1377,7 +1393,7 @@ default 'raise'
fold=None,
):
"""
implements datetime.replace, handles nanoseconds.
Implements datetime.replace, handles nanoseconds.

Parameters
----------
Expand Down