Skip to content

DOC: Fixing EX01 - Added examples #53725

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 8 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Worked on merge conflict
  • Loading branch information
DeaMariaLeon committed Jun 21, 2023
commit 109bed1d10adf522b11c5c1bbe25a3228a7e55cc
5 changes: 0 additions & 5 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.errors.UnsupportedFunctionCall \
pandas.test \
pandas.NaT \
pandas.Timestamp.strptime \
pandas.Timestamp.tzname \
pandas.Timestamp.utcoffset \
pandas.Timestamp.utctimetuple \
pandas.Timestamp.weekday \
pandas.arrays.TimedeltaArray \
pandas.Period.asfreq \
pandas.Period.now \
Expand Down
3 changes: 1 addition & 2 deletions doc/source/whatsnew/v2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,8 @@ Datetimelike
^^^^^^^^^^^^
- :meth:`DatetimeIndex.map` with ``na_action="ignore"`` now works as expected. (:issue:`51644`)
- Bug in :func:`date_range` when ``freq`` was a :class:`DateOffset` with ``nanoseconds`` (:issue:`46877`)
- Bug in :meth:`Timestamp.date`, :meth:`Timestamp.isocalendar` were returning incorrect results for inputs outside those supported by the Python standard library's datetime module (:issue:`53668`)
- Bug in :meth:`Timestamp.date`, :meth:`Timestamp.isocalendar`, :meth:`Timestamp.timetuple`, and :meth:`Timestamp.toordinal` were returning incorrect results for inputs outside those supported by the Python standard library's datetime module (:issue:`53668`)
- Bug in :meth:`Timestamp.round` with values close to the implementation bounds returning incorrect results instead of raising ``OutOfBoundsDatetime`` (:issue:`51494`)
- Bug in :meth:`Timestamp.timetuple` and :meth:`Timestamp.toordinal` were returning incorrect results for inputs outside those supported by the Python standard library's datetime module (:issue:`53668`)
- Bug in :meth:`arrays.DatetimeArray.map` and :meth:`DatetimeIndex.map`, where the supplied callable operated array-wise instead of element-wise (:issue:`51977`)
- Bug in constructing a :class:`Series` or :class:`DataFrame` from a datetime or timedelta scalar always inferring nanosecond resolution instead of inferring from the input (:issue:`52212`)
- Bug in parsing datetime strings with weekday but no day e.g. "2023 Sept Thu" incorrectly raising ``AttributeError`` instead of ``ValueError`` (:issue:`52659`)
Expand Down
41 changes: 38 additions & 3 deletions pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,6 @@ class NaTType(_NaT):
""",
)
# _nat_methods
utctimetuple = _make_error_func("utctimetuple", datetime)
tzname = _make_error_func("tzname", datetime)
utcoffset = _make_error_func("utcoffset", datetime)

# "fromisocalendar" was introduced in 3.8
fromisocalendar = _make_error_func("fromisocalendar", datetime)
Expand Down Expand Up @@ -588,6 +585,44 @@ class NaTType(_NaT):
"""
Return UTC time tuple, compatible with time.localtime().

Examples
--------
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
>>> ts
Timestamp('2023-01-01 10:00:00+0100', tz='Europe/Brussels')
>>> ts.utctimetuple()
time.struct_time(tm_year=2023, tm_mon=1, tm_mday=1, tm_hour=9,
tm_min=0, tm_sec=0, tm_wday=6, tm_yday=1, tm_isdst=0)
"""
)
utcoffset = _make_error_func(
"utcoffset",
"""
Return utc offset.

Examples
--------
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
>>> ts
Timestamp('2023-01-01 10:00:00+0100', tz='Europe/Brussels')
>>> ts.utcoffset()
datetime.timedelta(seconds=3600)
"""
)
tzname = _make_error_func(
"tzname",
"""
Return time zone name.

Examples
--------
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
>>> ts
Timestamp('2023-01-01 10:00:00+0100', tz='Europe/Brussels')
>>> ts.tzname()
'CET'
"""
)
time = _make_error_func(
"time",
"""
Expand Down
43 changes: 43 additions & 0 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,49 @@ class Timestamp(_Timestamp):
) from err
return _dt.isocalendar()

def tzname(self):
"""
Return time zone name.

Examples
--------
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
>>> ts
Timestamp('2023-01-01 10:00:00+0100', tz='Europe/Brussels')
>>> ts.tzname()
'CET'
"""
return super().tzname()

def utcoffset(self):
"""
Return utc offset.

Examples
--------
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
>>> ts
Timestamp('2023-01-01 10:00:00+0100', tz='Europe/Brussels')
>>> ts.utcoffset()
datetime.timedelta(seconds=3600)
"""
return super().utcoffset()

def utctimetuple(self):
"""
Return UTC time tuple, compatible with time.localtime().

Examples
--------
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
>>> ts
Timestamp('2023-01-01 10:00:00+0100', tz='Europe/Brussels')
>>> ts.utctimetuple()
time.struct_time(tm_year=2023, tm_mon=1, tm_mday=1, tm_hour=9,
tm_min=0, tm_sec=0, tm_wday=6, tm_yday=1, tm_isdst=0)
"""
return super().utctimetuple()

def time(self):
"""
Return time object with same time but with tzinfo=None.
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.