Skip to content

Commit e1fa8f1

Browse files
committed
Merge remote-tracking branch 'upstream/main' into test/fix
2 parents bad694e + eaabb41 commit e1fa8f1

File tree

191 files changed

+2298
-1360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+2298
-1360
lines changed

ci/code_checks.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7272
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
7373
-i "pandas.Period.freq GL08" \
7474
-i "pandas.Period.ordinal GL08" \
75+
-i "pandas.errors.ChainedAssignmentError SA01" \
7576
-i "pandas.errors.IncompatibleFrequency SA01,SS06,EX01" \
7677
-i "pandas.api.extensions.ExtensionArray.value_counts EX01,RT03,SA01" \
7778
-i "pandas.api.typing.DataFrameGroupBy.plot PR02" \

doc/source/whatsnew/v3.0.0.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ process in more detail.
117117

118118
`PDEP-7: Consistent copy/view semantics in pandas with Copy-on-Write <https://pandas.pydata.org/pdeps/0007-copy-on-write.html>`__
119119

120+
Setting the option ``mode.copy_on_write`` no longer has any impact. The option is deprecated
121+
and will be removed in pandas 4.0.
122+
120123
.. _whatsnew_300.enhancements.col:
121124

122125
``pd.col`` syntax can now be used in :meth:`DataFrame.assign` and :meth:`DataFrame.loc`
@@ -748,11 +751,16 @@ Other API changes
748751
the dtype of the resulting Index (:issue:`60797`)
749752
- :class:`IncompatibleFrequency` now subclasses ``TypeError`` instead of ``ValueError``. As a result, joins with mismatched frequencies now cast to object like other non-comparable joins, and arithmetic with indexes with mismatched frequencies align (:issue:`55782`)
750753
- :class:`Series` "flex" methods like :meth:`Series.add` no longer allow passing a :class:`DataFrame` for ``other``; use the DataFrame reversed method instead (:issue:`46179`)
754+
- :func:`date_range` and :func:`timedelta_range` no longer default to ``unit="ns"``, instead will infer a unit from the ``start``, ``end``, and ``freq`` parameters. Explicitly specify a desired ``unit`` to override these (:issue:`59031`)
751755
- :meth:`CategoricalIndex.append` no longer attempts to cast different-dtype indexes to the caller's dtype (:issue:`41626`)
752756
- :meth:`ExtensionDtype.construct_array_type` is now a regular method instead of a ``classmethod`` (:issue:`58663`)
753757
- Arithmetic operations between a :class:`Series`, :class:`Index`, or :class:`ExtensionArray` with a ``list`` now consistently wrap that list with an array equivalent to ``Series(my_list).array``. To do any other kind of type inference or casting, do so explicitly before operating (:issue:`62552`)
754758
- Comparison operations between :class:`Index` and :class:`Series` now consistently return :class:`Series` regardless of which object is on the left or right (:issue:`36759`)
755759
- Numpy functions like ``np.isinf`` that return a bool dtype when called on a :class:`Index` object now return a bool-dtype :class:`Index` instead of ``np.ndarray`` (:issue:`52676`)
760+
- Methods that can operate in-place (:meth:`~DataFrame.replace`, :meth:`~DataFrame.fillna`,
761+
:meth:`~DataFrame.ffill`, :meth:`~DataFrame.bfill`, :meth:`~DataFrame.interpolate`,
762+
:meth:`~DataFrame.where`, :meth:`~DataFrame.mask`, :meth:`~DataFrame.clip`) now return
763+
the modified DataFrame or Series (``self``) instead of ``None`` when ``inplace=True`` (:issue:`63207`)
756764

757765
.. ---------------------------------------------------------------------------
758766
.. _whatsnew_300.deprecations:
@@ -1185,6 +1193,7 @@ I/O
11851193
- Fix bug in ``on_bad_lines`` callable when returning too many fields: now emits
11861194
``ParserWarning`` and truncates extra fields regardless of ``index_col`` (:issue:`61837`)
11871195
- Bug in :func:`pandas.json_normalize` inconsistently handling non-dict items in ``data`` when ``max_level`` was set. The function will now raise a ``TypeError`` if ``data`` is a list containing non-dict items (:issue:`62829`)
1196+
- Bug in :func:`pandas.json_normalize` raising ``TypeError`` when ``meta`` contained a non-string key (e.g., ``int``) and ``record_path`` was specified, which was inconsistent with the behavior when ``record_path`` was ``None`` (:issue:`63019`)
11881197
- Bug in :meth:`.DataFrame.to_json` when ``"index"`` was a value in the :attr:`DataFrame.column` and :attr:`Index.name` was ``None``. Now, this will fail with a ``ValueError`` (:issue:`58925`)
11891198
- Bug in :meth:`.io.common.is_fsspec_url` not recognizing chained fsspec URLs (:issue:`48978`)
11901199
- Bug in :meth:`DataFrame._repr_html_` which ignored the ``"display.float_format"`` option (:issue:`59876`)
@@ -1306,6 +1315,7 @@ Sparse
13061315
- Bug in :class:`SparseDtype` for equal comparison with na fill value. (:issue:`54770`)
13071316
- Bug in :meth:`DataFrame.sparse.from_spmatrix` which hard coded an invalid ``fill_value`` for certain subtypes. (:issue:`59063`)
13081317
- Bug in :meth:`DataFrame.sparse.to_dense` which ignored subclassing and always returned an instance of :class:`DataFrame` (:issue:`59913`)
1318+
- Bug in :meth:`cumsum` for integer arrays Calling SparseArray.cumsum caused max recursion depth error. (:issue:`62669`)
13091319

13101320
ExtensionArray
13111321
^^^^^^^^^^^^^^

pandas/_libs/hashtable_class_helper.pxi.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ cdef class StringHashTable(HashTable):
10701070
val = values[i]
10711071

10721072
if isinstance(val, str):
1073-
# GH#31499 if we have a np.str_ PyUnicode_AsUTF8 won't recognize
1073+
# GH#31499 if we have an np.str_ PyUnicode_AsUTF8 won't recognize
10741074
# it as a str, even though isinstance does.
10751075
v = PyUnicode_AsUTF8(<str>val)
10761076
else:
@@ -1108,7 +1108,7 @@ cdef class StringHashTable(HashTable):
11081108
val = values[i]
11091109

11101110
if isinstance(val, str):
1111-
# GH#31499 if we have a np.str_ PyUnicode_AsUTF8 won't recognize
1111+
# GH#31499 if we have an np.str_ PyUnicode_AsUTF8 won't recognize
11121112
# it as a str, even though isinstance does.
11131113
v = PyUnicode_AsUTF8(<str>val)
11141114
else:

pandas/_libs/index.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ cdef bint is_definitely_invalid_key(object val):
5858

5959
cdef ndarray _get_bool_indexer(ndarray values, object val, ndarray mask = None):
6060
"""
61-
Return a ndarray[bool] of locations where val matches self.values.
61+
Return an ndarray[bool] of locations where val matches self.values.
6262
6363
If val is not NA, this is equivalent to `self.values == val`
6464
"""

pandas/_libs/lib.pyx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ from pandas._libs.tslibs.nattype cimport (
106106
)
107107
from pandas._libs.tslibs.offsets cimport is_offset_object
108108
from pandas._libs.tslibs.period cimport is_period_object
109-
from pandas._libs.tslibs.timedeltas cimport convert_to_timedelta64
110109
from pandas._libs.tslibs.timezones cimport tz_compare
111110

112111
# constants that will be compared to potentially arbitrarily large
@@ -2674,11 +2673,6 @@ def maybe_convert_objects(ndarray[object] objects,
26742673
elif is_timedelta(val):
26752674
if convert_non_numeric:
26762675
seen.timedelta_ = True
2677-
try:
2678-
convert_to_timedelta64(val, "ns")
2679-
except OutOfBoundsTimedelta:
2680-
seen.object_ = True
2681-
break
26822676
break
26832677
else:
26842678
seen.object_ = True

pandas/_libs/tslib.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def format_array_from_datetime(
120120
NPY_DATETIMEUNIT reso=NPY_FR_ns,
121121
) -> np.ndarray:
122122
"""
123-
return a np object array of the string formatted values
123+
return an np object array of the string formatted values
124124

125125
Parameters
126126
----------

pandas/_libs/tslibs/conversion.pxd

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ cdef int64_t get_datetime64_nanos(object val, NPY_DATETIMEUNIT reso) except? -1
4545

4646
cpdef datetime localize_pydatetime(datetime dt, tzinfo tz)
4747
cdef int64_t cast_from_unit(object ts, str unit, NPY_DATETIMEUNIT out_reso=*) except? -1
48-
cdef (int64_t, int) precision_from_unit(
49-
NPY_DATETIMEUNIT in_reso, NPY_DATETIMEUNIT out_reso=*
50-
)
5148

5249
cdef maybe_localize_tso(_TSObject obj, tzinfo tz, NPY_DATETIMEUNIT reso)
5350

pandas/_libs/tslibs/conversion.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ cdef (int64_t, int) precision_from_unit(
276276

277277
cdef int64_t get_datetime64_nanos(object val, NPY_DATETIMEUNIT reso) except? -1:
278278
"""
279-
Extract the value and unit from a np.datetime64 object, then convert the
279+
Extract the value and unit from an np.datetime64 object, then convert the
280280
value to nanoseconds if necessary.
281281
"""
282282
cdef:

pandas/_libs/tslibs/nattype.pyx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,9 @@ class NaTType(_NaT):
12601260
Return new Timestamp object representing current time local to tz.
12611261
12621262
This method returns a new `Timestamp` object that represents the current time.
1263-
If a timezone is provided, the current time will be localized to that timezone.
1263+
If a timezone is provided, either through a timezone object or an IANA
1264+
standard timezone identifier, the current time will be localized to that
1265+
timezone.
12641266
Otherwise, it returns the current local time.
12651267
12661268
Parameters
@@ -1279,6 +1281,11 @@ class NaTType(_NaT):
12791281
>>> pd.Timestamp.now() # doctest: +SKIP
12801282
Timestamp('2020-11-16 22:06:16.378782')
12811283
1284+
If you want a specific timezone, in this case 'Brazil/East':
1285+
1286+
>>> pd.Timestamp.now('Brazil/East') # doctest: +SKIP
1287+
Timestamp('2025-11-11 22:17:59.609943-03:00)
1288+
12821289
Analogous for ``pd.NaT``:
12831290
12841291
>>> pd.NaT.now()
@@ -1885,7 +1892,7 @@ cdef bint checknull_with_nat(object val):
18851892

18861893
cdef bint is_dt64nat(object val):
18871894
"""
1888-
Is this a np.datetime64 object np.datetime64("NaT").
1895+
Is this an np.datetime64 object np.datetime64("NaT").
18891896
"""
18901897
if cnp.is_datetime64_object(val):
18911898
return cnp.get_datetime64_value(val) == NPY_NAT
@@ -1894,7 +1901,7 @@ cdef bint is_dt64nat(object val):
18941901

18951902
cdef bint is_td64nat(object val):
18961903
"""
1897-
Is this a np.timedelta64 object np.timedelta64("NaT").
1904+
Is this an np.timedelta64 object np.timedelta64("NaT").
18981905
"""
18991906
if cnp.is_timedelta64_object(val):
19001907
return cnp.get_timedelta64_value(val) == NPY_NAT

pandas/_libs/tslibs/np_datetime.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class OutOfBoundsTimedelta(ValueError):
208208
209209
Examples
210210
--------
211-
>>> pd.date_range(start="1/1/1700", freq="B", periods=100000)
211+
>>> pd.date_range(start="1/1/1700", freq="B", periods=100000, unit="ns")
212212
Traceback (most recent call last):
213213
OutOfBoundsTimedelta: Cannot cast 139999 days 00:00:00
214214
to unit='ns' without overflow.

0 commit comments

Comments
 (0)