Skip to content

Commit 1dd30ee

Browse files
authored
Merge branch 'main' into test-gh49052-where-nullable-dtype
2 parents e19e415 + 945385d commit 1dd30ee

File tree

179 files changed

+2369
-1054
lines changed

Some content is hidden

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

179 files changed

+2369
-1054
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ci:
1919
skip: [pyright, mypy]
2020
repos:
2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.14.3
22+
rev: v0.14.7
2323
hooks:
2424
- id: ruff
2525
args: [--exit-non-zero-on-fix]
@@ -71,7 +71,7 @@ repos:
7171
hooks:
7272
- id: isort
7373
- repo: https://github.com/asottile/pyupgrade
74-
rev: v3.21.0
74+
rev: v3.21.2
7575
hooks:
7676
- id: pyupgrade
7777
args: [--py311-plus]
@@ -87,12 +87,12 @@ repos:
8787
types: [text] # overwrite types: [rst]
8888
types_or: [python, rst]
8989
- repo: https://github.com/sphinx-contrib/sphinx-lint
90-
rev: v1.0.1
90+
rev: v1.0.2
9191
hooks:
9292
- id: sphinx-lint
9393
args: ["--enable", "all", "--disable", "line-too-long"]
9494
- repo: https://github.com/pre-commit/mirrors-clang-format
95-
rev: v21.1.2
95+
rev: v21.1.6
9696
hooks:
9797
- id: clang-format
9898
files: ^pandas/_libs/src|^pandas/_libs/include

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: 9 additions & 1 deletion
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`
@@ -381,6 +384,8 @@ In cases with mixed-resolution inputs, the highest resolution is used:
381384
382385
.. warning:: Many users will now get "M8[us]" dtype data in cases when they used to get "M8[ns]". For most use cases they should not notice a difference. One big exception is converting to integers, which will give integers 1000x smaller.
383386

387+
Similarly, the :class:`Timedelta` constructor and :func:`to_timedelta` with a string input now defaults to a microsecond unit, using nanosecond unit only in cases that actually have nanosecond precision.
388+
384389
.. _whatsnew_300.api_breaking.concat_datetime_sorting:
385390

386391
:func:`concat` no longer ignores ``sort`` when all objects have a :class:`DatetimeIndex`
@@ -748,6 +753,7 @@ Other API changes
748753
the dtype of the resulting Index (:issue:`60797`)
749754
- :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`)
750755
- :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`)
756+
- :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`)
751757
- :meth:`CategoricalIndex.append` no longer attempts to cast different-dtype indexes to the caller's dtype (:issue:`41626`)
752758
- :meth:`ExtensionDtype.construct_array_type` is now a regular method instead of a ``classmethod`` (:issue:`58663`)
753759
- 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`)
@@ -1273,7 +1279,8 @@ Groupby/resample/rolling
12731279
- Bug in :meth:`Rolling.apply` for ``method="table"`` where column order was not being respected due to the columns getting sorted by default. (:issue:`59666`)
12741280
- Bug in :meth:`Rolling.apply` where the applied function could be called on fewer than ``min_period`` periods if ``method="table"``. (:issue:`58868`)
12751281
- Bug in :meth:`Rolling.sem` computing incorrect results because it divided by ``sqrt((n - 1) * (n - ddof))`` instead of ``sqrt(n * (n - ddof))``. (:issue:`63180`)
1276-
- Bug in :meth:`Rolling.skew` incorrectly computing skewness for windows following outliers due to numerical instability. The calculation now properly handles catastrophic cancellation by recomputing affected windows (:issue:`47461`)
1282+
- Bug in :meth:`Rolling.skew` and in :meth:`Rolling.kurt` incorrectly computing skewness and kurtosis, respectively, for windows following outliers due to numerical instability. The calculation now properly handles catastrophic cancellation by recomputing affected windows (:issue:`47461`, :issue:`61416`)
1283+
- Bug in :meth:`Rolling.skew` and in :meth:`Rolling.kurt` where results varied with input length despite identical data and window contents (:issue:`54380`)
12771284
- Bug in :meth:`Series.resample` could raise when the date range ended shortly before a non-existent time. (:issue:`58380`)
12781285
- Bug in :meth:`Series.resample` raising error when resampling non-nanosecond resolutions out of bounds for nanosecond precision (:issue:`57427`)
12791286
- Bug in :meth:`Series.rolling.var` and :meth:`Series.rolling.std` computing incorrect results due to numerical instability. (:issue:`47721`, :issue:`52407`, :issue:`54518`, :issue:`55343`)
@@ -1311,6 +1318,7 @@ Sparse
13111318
- Bug in :class:`SparseDtype` for equal comparison with na fill value. (:issue:`54770`)
13121319
- Bug in :meth:`DataFrame.sparse.from_spmatrix` which hard coded an invalid ``fill_value`` for certain subtypes. (:issue:`59063`)
13131320
- Bug in :meth:`DataFrame.sparse.to_dense` which ignored subclassing and always returned an instance of :class:`DataFrame` (:issue:`59913`)
1321+
- Bug in :meth:`cumsum` for integer arrays Calling SparseArray.cumsum caused max recursion depth error. (:issue:`62669`)
13141322

13151323
ExtensionArray
13161324
^^^^^^^^^^^^^^

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/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/nattype.pyx

Lines changed: 8 additions & 1 deletion
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()

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.

pandas/_libs/tslibs/timedeltas.pxd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ cpdef int64_t get_unit_for_round(freq, NPY_DATETIMEUNIT creso) except? -1
99
cpdef int64_t delta_to_nanoseconds(
1010
delta, NPY_DATETIMEUNIT reso=*, bint round_ok=*
1111
) except? -1
12-
cdef convert_to_timedelta64(object ts, str unit)
1312
cdef bint is_any_td_scalar(object obj)
1413

1514

pandas/_libs/tslibs/timedeltas.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def array_to_timedelta64(
7171
values: npt.NDArray[np.object_],
7272
unit: str | None = ...,
7373
errors: str = ...,
74+
creso: int = ...,
7475
) -> np.ndarray: ... # np.ndarray[m8ns]
7576
def parse_timedelta_unit(unit: str | None) -> UnitChoices: ...
7677
def delta_to_nanoseconds(

0 commit comments

Comments
 (0)