Skip to content

Commit a695dc4

Browse files
committed
Merge branch 'main' into fix-rolling-std-custom-weights
2 parents dc16ff8 + ebca6df commit a695dc4

Some content is hidden

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

66 files changed

+985
-286
lines changed

.github/workflows/unit-tests.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,13 @@ jobs:
230230
git -c user.email="[email protected]" merge --no-commit my_ref_name
231231
fi
232232
- name: Build environment and Run Tests
233+
# https://github.com/numpy/numpy/issues/24703#issuecomment-1722379388
233234
run: |
234235
/opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev
235236
. ~/virtualenvs/pandas-dev/bin/activate
236-
python -m pip install --no-cache-dir -U pip wheel setuptools meson[ninja]==1.0.1 meson-python==0.13.1
237-
python -m pip install --no-cache-dir versioneer[toml] "cython<3.0.1" numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1
237+
python -m pip install --no-cache-dir -U pip wheel setuptools meson[ninja]==1.2.1 meson-python==0.13.1
238+
python -m pip install numpy --config-settings=setup-args="-Dallow-noblas=true"
239+
python -m pip install --no-cache-dir versioneer[toml] cython python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1
238240
python -m pip install --no-cache-dir --no-build-isolation -e .
239241
python -m pip list --no-cache-dir
240242
export PANDAS_CI=1
@@ -271,8 +273,8 @@ jobs:
271273
run: |
272274
/opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev
273275
. ~/virtualenvs/pandas-dev/bin/activate
274-
python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.0.1
275-
python -m pip install --no-cache-dir versioneer[toml] "cython<3.0.1" numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1
276+
python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.2.1
277+
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1
276278
python -m pip install --no-cache-dir --no-build-isolation -e .
277279
python -m pip list --no-cache-dir
278280
@@ -342,10 +344,10 @@ jobs:
342344
- name: Build Environment
343345
run: |
344346
python --version
345-
python -m pip install --upgrade pip setuptools wheel meson[ninja]==1.0.1 meson-python==0.13.1
347+
python -m pip install --upgrade pip setuptools wheel meson[ninja]==1.2.1 meson-python==0.13.1
346348
python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
347349
python -m pip install versioneer[toml]
348-
python -m pip install python-dateutil pytz tzdata "cython<3.0.1" hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-cov pytest-asyncio>=0.17
350+
python -m pip install python-dateutil pytz tzdata cython hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-cov pytest-asyncio>=0.17
349351
python -m pip install -ve . --no-build-isolation --no-index
350352
python -m pip list
351353

ci/deps/actions-310.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ dependencies:
66

77
# build dependencies
88
- versioneer[toml]
9-
- cython>=0.29.33, <3.0.1
10-
- meson[ninja]=1.0.1
9+
- cython>=0.29.33
10+
- meson[ninja]=1.2.1
1111
- meson-python=0.13.1
1212

1313
# test dependencies

ci/deps/actions-311-downstream_compat.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ dependencies:
77

88
# build dependencies
99
- versioneer[toml]
10-
- cython>=0.29.33, <3.0.1
11-
- meson[ninja]=1.0.1
10+
- cython>=0.29.33
11+
- meson[ninja]=1.2.1
1212
- meson-python=0.13.1
1313

1414
# test dependencies

ci/deps/actions-311-numpydev.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ dependencies:
66

77
# build dependencies
88
- versioneer[toml]
9-
- meson[ninja]=1.0.1
9+
- meson[ninja]=1.2.1
1010
- meson-python=0.13.1
11+
- cython>=0.29.33
1112

1213
# test dependencies
1314
- pytest>=7.3.2
@@ -25,7 +26,6 @@ dependencies:
2526
- pip
2627

2728
- pip:
28-
- "cython<3.0.1"
2929
- "--extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple"
3030
- "--pre"
3131
- "numpy"

ci/deps/actions-311-pyarrownightly.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ dependencies:
66

77
# build dependencies
88
- versioneer[toml]
9-
- meson[ninja]=1.0.1
10-
- cython>=0.29.33, <3.0.1
9+
- meson[ninja]=1.2.1
10+
- cython>=0.29.33
1111
- meson-python=0.13.1
1212

1313
# test dependencies

ci/deps/actions-311.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ dependencies:
66

77
# build dependencies
88
- versioneer[toml]
9-
- cython>=0.29.33, <3.0.1
10-
- meson[ninja]=1.0.1
9+
- cython>=0.29.33
10+
- meson[ninja]=1.2.1
1111
- meson-python=0.13.1
1212

1313
# test dependencies

ci/deps/actions-39-minimum_versions.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ dependencies:
88

99
# build dependencies
1010
- versioneer[toml]
11-
- cython>=0.29.33, <3.0.1
12-
- meson[ninja]=1.0.1
11+
- cython>=0.29.33
12+
- meson[ninja]=1.2.1
1313
- meson-python=0.13.1
1414

1515
# test dependencies

ci/deps/actions-39.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ dependencies:
66

77
# build dependencies
88
- versioneer[toml]
9-
- cython>=0.29.33, <3.0.1
10-
- meson[ninja]=1.0.1
9+
- cython>=0.29.33
10+
- meson[ninja]=1.2.1
1111
- meson-python=0.13.1
1212

1313
# test dependencies

ci/deps/actions-pypy-39.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ dependencies:
99

1010
# build dependencies
1111
- versioneer[toml]
12-
- cython>=0.29.33, <3.0.1
13-
- meson[ninja]=1.0.1
12+
- cython>=0.29.33
13+
- meson[ninja]=1.2.1
1414
- meson-python=0.13.1
1515

1616
# test dependencies

ci/deps/circle-310-arm64.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ dependencies:
66

77
# build dependencies
88
- versioneer[toml]
9-
- cython>=0.29.33, <3.0.1
10-
- meson[ninja]=1.0.1
9+
- cython>=0.29.33
10+
- meson[ninja]=1.2.1
1111
- meson-python=0.13.1
1212

1313
# test dependencies

doc/source/reference/extensions.rst

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ objects.
3434
3535
api.extensions.ExtensionArray._accumulate
3636
api.extensions.ExtensionArray._concat_same_type
37+
api.extensions.ExtensionArray._explode
3738
api.extensions.ExtensionArray._formatter
3839
api.extensions.ExtensionArray._from_factorized
3940
api.extensions.ExtensionArray._from_sequence

doc/source/reference/series.rst

+23
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,29 @@ Sparse-dtype specific methods and attributes are provided under the
525525
Series.sparse.from_coo
526526
Series.sparse.to_coo
527527

528+
529+
.. _api.series.struct:
530+
531+
Struct accessor
532+
~~~~~~~~~~~~~~~
533+
534+
Arrow struct-dtype specific methods and attributes are provided under the
535+
``Series.struct`` accessor.
536+
537+
.. autosummary::
538+
:toctree: api/
539+
:template: autosummary/accessor_attribute.rst
540+
541+
Series.struct.dtypes
542+
543+
.. autosummary::
544+
:toctree: api/
545+
:template: autosummary/accessor_method.rst
546+
547+
Series.struct.field
548+
Series.struct.explode
549+
550+
528551
.. _api.series.flags:
529552

530553
Flags

doc/source/user_guide/gotchas.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ constructors using something similar to the following:
379379
.. ipython:: python
380380
381381
x = np.array(list(range(10)), ">i4") # big endian
382-
newx = x.byteswap().newbyteorder() # force native byteorder
382+
newx = x.byteswap().view(x.dtype.newbyteorder()) # force native byteorder
383383
s = pd.Series(newx)
384384
385385
See `the NumPy documentation on byte order

doc/source/user_guide/missing_data.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ Limit the number of NA values filled
401401
402402
df.ffill(limit=1)
403403
404-
NA values can be replaced with corresponding value from a :class:`Series`` or :class:`DataFrame``
404+
NA values can be replaced with corresponding value from a :class:`Series` or :class:`DataFrame`
405405
where the index and column aligns between the original object and the filled object.
406406

407407
.. ipython:: python
@@ -660,7 +660,7 @@ Pass a list of regular expressions that will replace matches with a scalar.
660660

661661
.. ipython:: python
662662
663-
df.replace([r"\s*\.\s*", r"a|b"], np.nan, regex=True)
663+
df.replace([r"\s*\.\s*", r"a|b"], "placeholder", regex=True)
664664
665665
All of the regular expression examples can also be passed with the
666666
``to_replace`` argument as the ``regex`` argument. In this case the ``value``
@@ -669,7 +669,7 @@ dictionary.
669669

670670
.. ipython:: python
671671
672-
df.replace(regex=[r"\s*\.\s*", r"a|b"], value=np.nan)
672+
df.replace(regex=[r"\s*\.\s*", r"a|b"], value="placeholder")
673673
674674
.. note::
675675

doc/source/whatsnew/v0.14.0.rst

+8-2
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,15 @@ More consistent behavior for some groupby methods:
349349
350350
- groupby head and tail respect column selection:
351351

352-
.. ipython:: python
352+
.. code-block:: ipython
353+
354+
In [19]: g[['B']].head(1)
355+
Out[19]:
356+
B
357+
0 2
358+
2 6
353359
354-
g[['B']].head(1)
360+
[2 rows x 1 columns]
355361
356362
- groupby ``nth`` now reduces by default; filtering can be achieved by passing ``as_index=False``. With an optional ``dropna`` argument to ignore
357363
NaN. See :ref:`the docs <groupby.nth>`.

doc/source/whatsnew/v2.2.0.rst

+35-4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,34 @@ There are two advantages of this engine:
3636
3737
For more, see :ref:`io.calamine` in the user guide on IO tools.
3838

39+
.. _whatsnew_220.enhancements.struct_accessor:
40+
41+
Series.struct accessor to with PyArrow structured data
42+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43+
44+
The ``Series.struct`` accessor provides attributes and methods for processing
45+
data with ``struct[pyarrow]`` dtype Series. For example,
46+
:meth:`Series.struct.explode` converts PyArrow structured data to a pandas
47+
DataFrame. (:issue:`54938`)
48+
49+
.. ipython:: python
50+
51+
import pyarrow as pa
52+
series = pd.Series(
53+
[
54+
{"project": "pandas", "version": "2.2.0"},
55+
{"project": "numpy", "version": "1.25.2"},
56+
{"project": "pyarrow", "version": "13.0.0"},
57+
],
58+
dtype=pd.ArrowDtype(
59+
pa.struct([
60+
("project", pa.string()),
61+
("version", pa.string()),
62+
])
63+
),
64+
)
65+
series.struct.explode()
66+
3967
.. _whatsnew_220.enhancements.enhancement2:
4068

4169
enhancement2
@@ -45,6 +73,7 @@ enhancement2
4573

4674
Other enhancements
4775
^^^^^^^^^^^^^^^^^^
76+
- :meth:`ExtensionArray._explode` interface method added to allow extension type implementations of the ``explode`` method (:issue:`54833`)
4877
- DataFrame.apply now allows the usage of numba (via ``engine="numba"``) to JIT compile the passed function, allowing for potential speedups (:issue:`54666`)
4978
-
5079

@@ -162,13 +191,15 @@ Deprecations
162191
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_parquet` except ``path``. (:issue:`54229`)
163192
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_pickle` except ``path``. (:issue:`54229`)
164193
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_string` except ``buf``. (:issue:`54229`)
165-
- Deprecated downcasting behavior in :meth:`Series.where`, :meth:`DataFrame.where`, :meth:`Series.mask`, :meth:`DataFrame.mask`, :meth:`Series.clip`, :meth:`DataFrame.clip`; in a future version these will not infer object-dtype columns to non-object dtype, or all-round floats to integer dtype. Call ``result.infer_objects(copy=False)`` on the result for object inference, or explicitly cast floats to ints. To opt in to the future version, use ``pd.set_option("future.downcasting", True)`` (:issue:`53656`)
194+
- Deprecated automatic downcasting of object-dtype results in :meth:`Series.replace` and :meth:`DataFrame.replace`, explicitly call ``result = result.infer_objects(copy=False)`` instead. To opt in to the future version, use ``pd.set_option("future.no_silent_downcasting", True)`` (:issue:`54710`)
195+
- Deprecated downcasting behavior in :meth:`Series.where`, :meth:`DataFrame.where`, :meth:`Series.mask`, :meth:`DataFrame.mask`, :meth:`Series.clip`, :meth:`DataFrame.clip`; in a future version these will not infer object-dtype columns to non-object dtype, or all-round floats to integer dtype. Call ``result.infer_objects(copy=False)`` on the result for object inference, or explicitly cast floats to ints. To opt in to the future version, use ``pd.set_option("future.no_silent_downcasting", True)`` (:issue:`53656`)
166196
- Deprecated including the groups in computations when using :meth:`DataFrameGroupBy.apply` and :meth:`DataFrameGroupBy.resample`; pass ``include_groups=False`` to exclude the groups (:issue:`7155`)
167197
- Deprecated not passing a tuple to :class:`DataFrameGroupBy.get_group` or :class:`SeriesGroupBy.get_group` when grouping by a length-1 list-like (:issue:`25971`)
168198
- Deprecated strings ``S``, ``U``, and ``N`` denoting units in :func:`to_timedelta` (:issue:`52536`)
169199
- Deprecated strings ``T``, ``S``, ``L``, ``U``, and ``N`` denoting frequencies in :class:`Minute`, :class:`Second`, :class:`Milli`, :class:`Micro`, :class:`Nano` (:issue:`52536`)
170200
- Deprecated strings ``T``, ``S``, ``L``, ``U``, and ``N`` denoting units in :class:`Timedelta` (:issue:`52536`)
171201
- Deprecated the extension test classes ``BaseNoReduceTests``, ``BaseBooleanReduceTests``, and ``BaseNumericReduceTests``, use ``BaseReduceTests`` instead (:issue:`54663`)
202+
- Deprecating downcasting the results of :meth:`DataFrame.fillna`, :meth:`Series.fillna`, :meth:`DataFrame.ffill`, :meth:`Series.ffill`, :meth:`DataFrame.bfill`, :meth:`Series.bfill` in object-dtype cases. To opt in to the future version, use ``pd.set_option("future.no_silent_downcasting", True)`` (:issue:`54261`)
172203

173204
.. ---------------------------------------------------------------------------
174205
.. _whatsnew_220.performance:
@@ -230,12 +261,12 @@ Strings
230261

231262
Interval
232263
^^^^^^^^
233-
-
264+
- Bug in :class:`Interval` ``__repr__`` not displaying UTC offsets for :class:`Timestamp` bounds. Additionally the hour, minute and second components will now be shown. (:issue:`55015`)
234265
-
235266

236267
Indexing
237268
^^^^^^^^
238-
-
269+
- Bug in :meth:`Index.difference` not returning a unique set of values when ``other`` is empty or ``other`` is considered non-comparable (:issue:`55113`)
239270
-
240271

241272
Missing
@@ -261,7 +292,7 @@ Period
261292

262293
Plotting
263294
^^^^^^^^
264-
-
295+
- Bug in :meth:`DataFrame.plot.box` with ``vert=False`` and a matplotlib ``Axes`` created with ``sharey=True`` (:issue:`54941`)
265296
-
266297

267298
Groupby/resample/rolling

environment.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies:
99
# build dependencies
1010
- versioneer[toml]
1111
- cython=0.29.33
12-
- meson[ninja]=1.0.1
12+
- meson[ninja]=1.2.1
1313
- meson-python=0.13.1
1414

1515
# test dependencies
@@ -85,7 +85,7 @@ dependencies:
8585
- google-auth
8686
- natsort # DataFrame.sort_values doctest
8787
- numpydoc
88-
- pydata-sphinx-theme
88+
- pydata-sphinx-theme=0.13
8989
- pytest-cython # doctest
9090
- sphinx
9191
- sphinx-design

meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ project(
44
'c', 'cpp', 'cython',
55
version: run_command(['generate_version.py', '--print'], check: true).stdout().strip(),
66
license: 'BSD-3',
7-
meson_version: '>=1.0.1',
7+
meson_version: '>=1.2.1',
88
default_options: [
99
'buildtype=release',
1010
'c_std=c99'

pandas/_libs/interval.pyx

+3-18
Original file line numberDiff line numberDiff line change
@@ -478,31 +478,16 @@ cdef class Interval(IntervalMixin):
478478
args = (self.left, self.right, self.closed)
479479
return (type(self), args)
480480

481-
def _repr_base(self):
482-
left = self.left
483-
right = self.right
484-
485-
# TODO: need more general formatting methodology here
486-
if isinstance(left, _Timestamp) and isinstance(right, _Timestamp):
487-
left = left._short_repr
488-
right = right._short_repr
489-
490-
return left, right
491-
492481
def __repr__(self) -> str:
493-
494-
left, right = self._repr_base()
495-
disp = str if isinstance(left, np.generic) else repr
482+
disp = str if isinstance(self.left, (np.generic, _Timestamp)) else repr
496483
name = type(self).__name__
497-
repr_str = f"{name}({disp(left)}, {disp(right)}, closed={repr(self.closed)})"
484+
repr_str = f"{name}({disp(self.left)}, {disp(self.right)}, closed={repr(self.closed)})" # noqa: E501
498485
return repr_str
499486

500487
def __str__(self) -> str:
501-
502-
left, right = self._repr_base()
503488
start_symbol = "[" if self.closed_left else "("
504489
end_symbol = "]" if self.closed_right else ")"
505-
return f"{start_symbol}{left}, {right}{end_symbol}"
490+
return f"{start_symbol}{self.left}, {self.right}{end_symbol}"
506491

507492
def __add__(self, y):
508493
if (

pandas/_libs/tslibs/dtypes.pyx

-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ cdef NPY_DATETIMEUNIT freq_group_code_to_npy_unit(int freq) noexcept nogil:
460460
return NPY_DATETIMEUNIT.NPY_FR_D
461461

462462

463-
# TODO: use in _matplotlib.converter?
464463
cpdef int64_t periods_per_day(
465464
NPY_DATETIMEUNIT reso=NPY_DATETIMEUNIT.NPY_FR_ns
466465
) except? -1:

0 commit comments

Comments
 (0)