Skip to content

Commit 835365d

Browse files
committed
merge
2 parents d44d0f7 + bb0403b commit 835365d

26 files changed

+584
-255
lines changed

ci/code_checks.sh

-10
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
105105
pandas.errors.UnsupportedFunctionCall \
106106
pandas.test \
107107
pandas.NaT \
108-
pandas.Timestamp.strptime \
109-
pandas.Timestamp.time \
110-
pandas.Timestamp.timetuple \
111-
pandas.Timestamp.timetz \
112-
pandas.Timestamp.to_datetime64 \
113-
pandas.Timestamp.toordinal \
114-
pandas.Timestamp.tzname \
115-
pandas.Timestamp.utcoffset \
116-
pandas.Timestamp.utctimetuple \
117-
pandas.Timestamp.weekday \
118108
pandas.arrays.TimedeltaArray \
119109
pandas.Period.asfreq \
120110
pandas.Period.now \

doc/source/getting_started/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pandas is equipped with an exhaustive set of unit tests, covering about 97% of
216216
the code base as of this writing. To run it on your machine to verify that
217217
everything is working (and that you have all of the dependencies, soft and hard,
218218
installed), make sure you have `pytest
219-
<https://docs.pytest.org/en/latest/>`__ >= 7.0 and `Hypothesis
219+
<https://docs.pytest.org/en/latest/>`__ >= 7.3.2 and `Hypothesis
220220
<https://hypothesis.readthedocs.io/en/latest/>`__ >= 6.34.2, then run:
221221

222222
::

doc/source/whatsnew/v2.0.3.rst

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Bug fixes
2828
- Bug in :func:`read_csv` when defining ``dtype`` with ``bool[pyarrow]`` for the ``"c"`` and ``"python"`` engines (:issue:`53390`)
2929
- Bug in :meth:`Series.str.split` and :meth:`Series.str.rsplit` with ``expand=True`` for :class:`ArrowDtype` with ``pyarrow.string`` (:issue:`53532`)
3030
- Bug in indexing methods (e.g. :meth:`DataFrame.__getitem__`) where taking the entire :class:`DataFrame`/:class:`Series` would raise an ``OverflowError`` when Copy on Write was enabled and the length of the array was over the maximum size a 32-bit integer can hold (:issue:`53616`)
31+
- Bug when constructing a :class:`DataFrame` with columns of an :class:`ArrowDtype` with a ``pyarrow.dictionary`` type that reindexes the data (:issue:`53617`)
3132
- Bug when indexing a :class:`DataFrame` or :class:`Series` with an :class:`Index` with a timestamp :class:`ArrowDtype` would raise an ``AttributeError`` (:issue:`53644`)
3233

3334
.. ---------------------------------------------------------------------------

doc/source/whatsnew/v2.1.0.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Enhancements
1919
Copy-on-Write improvements
2020
^^^^^^^^^^^^^^^^^^^^^^^^^^
2121

22+
- :meth:`Series.transform` not respecting Copy-on-Write when ``func`` modifies :class:`Series` inplace (:issue:`53747`)
2223
- Calling :meth:`Index.values` will now return a read-only NumPy array (:issue:`53704`)
2324
- Setting a :class:`Series` into a :class:`DataFrame` now creates a lazy instead of a deep copy (:issue:`53142`)
2425
- The :class:`DataFrame` constructor, when constructing a DataFrame from a dictionary
@@ -193,6 +194,8 @@ If installed, we now require:
193194
+-----------------+-----------------+----------+---------+
194195
| pytables | 3.7.0 | | X |
195196
+-----------------+-----------------+----------+---------+
197+
| pytest | 7.3.2 | | X |
198+
+-----------------+-----------------+----------+---------+
196199
| python-snappy | 0.6.1 | | X |
197200
+-----------------+-----------------+----------+---------+
198201
| pyxlsb | 1.0.9 | | X |
@@ -288,6 +291,7 @@ Deprecations
288291
- Deprecated :func:`value_counts`, use ``pd.Series(obj).value_counts()`` instead (:issue:`47862`)
289292
- Deprecated :meth:`Series.first` and :meth:`DataFrame.first` (please create a mask and filter using ``.loc`` instead) (:issue:`45908`)
290293
- Deprecated :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` for object-dtype (:issue:`53631`)
294+
- Deprecated :meth:`Series.last` and :meth:`DataFrame.last` (please create a mask and filter using ``.loc`` instead) (:issue:`53692`)
291295
- Deprecated allowing ``downcast`` keyword other than ``None``, ``False``, "infer", or a dict with these as values in :meth:`Series.fillna`, :meth:`DataFrame.fillna` (:issue:`40988`)
292296
- Deprecated allowing arbitrary ``fill_value`` in :class:`SparseDtype`, in a future version the ``fill_value`` will need to be compatible with the ``dtype.subtype``, either a scalar that can be held by that subtype or ``NaN`` for integer or bool subtypes (:issue:`23124`)
293297
- Deprecated behavior of :func:`assert_series_equal` and :func:`assert_frame_equal` considering NA-like values (e.g. ``NaN`` vs ``None`` as equivalent) (:issue:`52081`)
@@ -358,12 +362,11 @@ Datetimelike
358362
^^^^^^^^^^^^
359363
- :meth:`DatetimeIndex.map` with ``na_action="ignore"`` now works as expected. (:issue:`51644`)
360364
- Bug in :func:`date_range` when ``freq`` was a :class:`DateOffset` with ``nanoseconds`` (:issue:`46877`)
361-
- 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`)
365+
- 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`)
362366
- Bug in :meth:`Timestamp.round` with values close to the implementation bounds returning incorrect results instead of raising ``OutOfBoundsDatetime`` (:issue:`51494`)
363367
- Bug in :meth:`arrays.DatetimeArray.map` and :meth:`DatetimeIndex.map`, where the supplied callable operated array-wise instead of element-wise (:issue:`51977`)
364368
- 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`)
365369
- Bug in parsing datetime strings with weekday but no day e.g. "2023 Sept Thu" incorrectly raising ``AttributeError`` instead of ``ValueError`` (:issue:`52659`)
366-
-
367370

368371
Timedelta
369372
^^^^^^^^^
@@ -491,7 +494,6 @@ Reshaping
491494
- Bug in :meth:`DataFrame.idxmin` and :meth:`DataFrame.idxmax`, where the axis dtype would be lost for empty frames (:issue:`53265`)
492495
- Bug in :meth:`DataFrame.merge` not merging correctly when having ``MultiIndex`` with single level (:issue:`52331`)
493496
- Bug in :meth:`DataFrame.stack` losing extension dtypes when columns is a :class:`MultiIndex` and frame contains mixed dtypes (:issue:`45740`)
494-
- Bug in :meth:`DataFrame.stack` would incorrectly order results when ``sort=True`` and the input had :class:`MultiIndex` levels that were not sorted (:issue:`53636`)
495497
- Bug in :meth:`DataFrame.transpose` inferring dtype for object column (:issue:`51546`)
496498
- Bug in :meth:`Series.combine_first` converting ``int64`` dtype to ``float64`` and losing precision on very large integers (:issue:`51764`)
497499
-

pandas/_libs/tslibs/nattype.pyx

+123-8
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,16 @@ cdef class _NaT(datetime):
256256

257257
def to_datetime64(self) -> np.datetime64:
258258
"""
259-
Return a numpy.datetime64 object with 'ns' precision.
259+
Return a numpy.datetime64 object with same precision.
260+
261+
Examples
262+
--------
263+
>>> ts = pd.Timestamp(year=2023, month=1, day=1,
264+
... hour=10, second=15)
265+
>>> ts
266+
Timestamp('2023-01-01 10:00:15')
267+
>>> ts.to_datetime64()
268+
numpy.datetime64('2023-01-01T10:00:15.000000')
260269
"""
261270
return np.datetime64("NaT", "ns")
262271

@@ -429,6 +438,14 @@ class NaTType(_NaT):
429438
Return the day of the week represented by the date.
430439
431440
Monday == 0 ... Sunday == 6.
441+
442+
Examples
443+
--------
444+
>>> ts = pd.Timestamp('2023-01-01')
445+
>>> ts
446+
Timestamp('2023-01-01 00:00:00')
447+
>>> ts.weekday()
448+
6
432449
""",
433450
)
434451
isoweekday = _make_nan_func(
@@ -514,13 +531,6 @@ class NaTType(_NaT):
514531
""",
515532
)
516533
# _nat_methods
517-
utctimetuple = _make_error_func("utctimetuple", datetime)
518-
timetz = _make_error_func("timetz", datetime)
519-
timetuple = _make_error_func("timetuple", datetime)
520-
time = _make_error_func("time", datetime)
521-
toordinal = _make_error_func("toordinal", datetime)
522-
tzname = _make_error_func("tzname", datetime)
523-
utcoffset = _make_error_func("utcoffset", datetime)
524534

525535
# "fromisocalendar" was introduced in 3.8
526536
fromisocalendar = _make_error_func("fromisocalendar", datetime)
@@ -570,7 +580,106 @@ class NaTType(_NaT):
570580
datetime.date(2023, 1, 1)
571581
"""
572582
)
583+
utctimetuple = _make_error_func(
584+
"utctimetuple",
585+
"""
586+
Return UTC time tuple, compatible with time.localtime().
587+
588+
Examples
589+
--------
590+
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
591+
>>> ts
592+
Timestamp('2023-01-01 10:00:00+0100', tz='Europe/Brussels')
593+
>>> ts.utctimetuple()
594+
time.struct_time(tm_year=2023, tm_mon=1, tm_mday=1, tm_hour=9,
595+
tm_min=0, tm_sec=0, tm_wday=6, tm_yday=1, tm_isdst=0)
596+
"""
597+
)
598+
utcoffset = _make_error_func(
599+
"utcoffset",
600+
"""
601+
Return utc offset.
602+
603+
Examples
604+
--------
605+
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
606+
>>> ts
607+
Timestamp('2023-01-01 10:00:00+0100', tz='Europe/Brussels')
608+
>>> ts.utcoffset()
609+
datetime.timedelta(seconds=3600)
610+
"""
611+
)
612+
tzname = _make_error_func(
613+
"tzname",
614+
"""
615+
Return time zone name.
616+
617+
Examples
618+
--------
619+
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
620+
>>> ts
621+
Timestamp('2023-01-01 10:00:00+0100', tz='Europe/Brussels')
622+
>>> ts.tzname()
623+
'CET'
624+
"""
625+
)
626+
time = _make_error_func(
627+
"time",
628+
"""
629+
Return time object with same time but with tzinfo=None.
630+
631+
Examples
632+
--------
633+
>>> ts = pd.Timestamp('2023-01-01 10:00:00')
634+
>>> ts
635+
Timestamp('2023-01-01 10:00:00')
636+
>>> ts.time()
637+
datetime.time(10, 0)
638+
""",
639+
)
640+
timetuple = _make_error_func(
641+
"timetuple",
642+
"""
643+
Return time tuple, compatible with time.localtime().
644+
645+
Examples
646+
--------
647+
>>> ts = pd.Timestamp('2023-01-01 10:00:00')
648+
>>> ts
649+
Timestamp('2023-01-01 10:00:00')
650+
>>> ts.timetuple()
651+
time.struct_time(tm_year=2023, tm_mon=1, tm_mday=1,
652+
tm_hour=10, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=1, tm_isdst=-1)
653+
"""
654+
)
655+
timetz = _make_error_func(
656+
"timetz",
657+
"""
658+
Return time object with same time and tzinfo.
659+
660+
Examples
661+
--------
662+
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
663+
>>> ts
664+
Timestamp('2023-01-01 10:00:00+0100', tz='Europe/Brussels')
665+
>>> ts.timetz()
666+
datetime.time(10, 0, tzinfo=<DstTzInfo 'Europe/Brussels' CET+1:00:00 STD>)
667+
"""
668+
)
669+
toordinal = _make_error_func(
670+
"toordinal",
671+
"""
672+
Return proleptic Gregorian ordinal. January 1 of year 1 is day 1.
573673
674+
Examples
675+
--------
676+
>>> ts = pd.Timestamp('2023-01-01 10:00:50')
677+
>>> ts
678+
Timestamp('2023-01-01 10:00:50')
679+
>>> ts.toordinal()
680+
738521
681+
"""
682+
)
574683
ctime = _make_error_func(
575684
"ctime",
576685
"""
@@ -612,6 +721,12 @@ class NaTType(_NaT):
612721
Timestamp.strptime(string, format)
613722
614723
Function is not implemented. Use pd.to_datetime().
724+
725+
Examples
726+
--------
727+
>>> pd.Timestamp.strptime("2023-01-01", "%d/%m/%y")
728+
Traceback (most recent call last):
729+
NotImplementedError
615730
""",
616731
)
617732

pandas/_libs/tslibs/period.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1917,7 +1917,8 @@ cdef class _Period(PeriodMixin):
19171917
Parameters
19181918
----------
19191919
freq : str, BaseOffset
1920-
The desired frequency.
1920+
The desired frequency. If passing a `str`, it needs to be a
1921+
valid :ref:`period alias <timeseries.period_aliases>`.
19211922
how : {'E', 'S', 'end', 'start'}, default 'end'
19221923
Start or end of the timespan.
19231924

0 commit comments

Comments
 (0)