Skip to content

Commit 435cbf1

Browse files
committed
Merge remote-tracking branch 'upstream/main' into bug/cow/index_readonly_input
2 parents 85c1a5f + f4cd63d commit 435cbf1

File tree

11 files changed

+179
-13
lines changed

11 files changed

+179
-13
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Announcement: pandas 3.0.0 release candidate ready for testing! Read more <a href="https://pandas.pydata.org/community/blog/pandas-3.0-release-candidate.html">in the blog post</a>

doc/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
# This shows a warning for patch releases since the
259259
# patch version doesn't compare as equal (e.g. 2.2.1 != 2.2.0 but it should be)
260260
"show_version_warning_banner": False,
261+
"announcement": "https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/_templates/docs-announcement-banner.html",
261262
"icon_links": [
262263
{
263264
"name": "X",

doc/source/whatsnew/v3.0.0.rst

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ and how to adapt your code to the new default.
8080

8181
.. _whatsnew_300.enhancements.copy_on_write:
8282

83-
Copy-on-Write
84-
^^^^^^^^^^^^^
83+
Consistent copy/view behaviour with Copy-on-Write
84+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8585

8686
The new "copy-on-write" behaviour in pandas 3.0 brings changes in behavior in
8787
how pandas operates with respect to copies and views. A summary of the changes:
@@ -101,9 +101,10 @@ copy or a view depended on the exact operation performed, which was often
101101
confusing).
102102

103103
Because every single indexing step now behaves as a copy, this also means that
104-
"chained assignment" (updating a DataFrame with multiple setitem steps) will
105-
stop working. Because this now consistently never works, the
106-
``SettingWithCopyWarning`` is removed.
104+
**"chained assignment"** (updating a DataFrame with multiple setitem steps)
105+
**will stop working**. Because this now consistently never works, the
106+
``SettingWithCopyWarning`` is removed, and defensive ``.copy()`` calls to
107+
silence the warning are no longer needed.
107108

108109
The new behavioral semantics are explained in more detail in the
109110
:ref:`user guide about Copy-on-Write <copy_on_write>`.
@@ -130,10 +131,18 @@ and will be removed in pandas 4.0.
130131

131132
.. _whatsnew_300.enhancements.col:
132133

133-
``pd.col`` syntax can now be used in :meth:`DataFrame.assign` and :meth:`DataFrame.loc`
134-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
134+
Initial support for ``pd.col()`` syntax to create expressions
135+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
135136

136-
You can now use ``pd.col`` to create callables for use in dataframe methods which accept them. For example, if you have a dataframe
137+
This release introduces :func:`col` to refer to a DataFrame column by name
138+
and build up expressions.
139+
140+
This can be used as a simplified syntax to create callables for use in
141+
methods such as :meth:`DataFrame.assign`. In practice, where you would
142+
have to use a ``lambda`` function before, you can now use ``pd.col()``
143+
instead.
144+
145+
For example, if you have a dataframe
137146

138147
.. ipython:: python
139148
@@ -151,6 +160,18 @@ you can now write:
151160
152161
df.assign(c = pd.col('a') + pd.col('b'))
153162
163+
The expression object returned by :func:`col` supports all standard operators
164+
(like ``+``, ``-``, ``*``, ``/``, etc.) and all Series methods and namespaces
165+
(like ``pd.col("name").sum()``, ``pd.col("name").str.upper()``, etc.).
166+
167+
Currently, the ``pd.col()`` syntax can be used in any place which accepts a
168+
callable that takes the calling DataFrame as first argument and returns a
169+
Series, like ``lambda df: df[col_name]``.
170+
This includes :meth:`DataFrame.assign`, :meth:`DataFrame.loc`, and getitem/setitem.
171+
172+
It is expected that the support for ``pd.col()`` will be expanded to more methods
173+
in future releases.
174+
154175
New Deprecation Policy
155176
^^^^^^^^^^^^^^^^^^^^^^
156177
pandas 3.0.0 introduces a new 3-stage deprecation policy: using ``DeprecationWarning`` initially, then switching to ``FutureWarning`` for broader visibility in the last minor version before the next major release, and then removal of the deprecated functionality in the major release. This was done to give downstream packages more time to adjust to pandas deprecations, which should reduce the amount of warnings that a user gets from code that isn't theirs. See `PDEP 17 <https://pandas.pydata.org/pdeps/0017-backwards-compatibility-and-deprecation-policy.html>`_ for more details.

environment.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ dependencies:
8686
- natsort # DataFrame.sort_values doctest
8787
- pickleshare # Needed for IPython Sphinx directive in the docs GH#60429
8888
- numpydoc
89-
- pydata-sphinx-theme=0.16
89+
# temporary installed with pip with custom patch until released
90+
# - pydata-sphinx-theme=0.16
9091
- pytest-cython # doctest
9192
- sphinx
9293
- sphinx-design
@@ -126,3 +127,4 @@ dependencies:
126127

127128
- pip:
128129
- tzdata>=2023.3
130+
- https://github.com/jorisvandenbossche/pydata-sphinx-theme/archive/refs/heads/v0.16.1+dismissable-announcement-banner.zip

pandas/core/col.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ def col(col_name: Hashable) -> Expression:
260260
:meth:`DataFrame.assign` or :meth:`DataFrame.loc`, can also accept
261261
``pd.col(col_name)``.
262262
263+
.. versionadded:: 3.0.0
264+
263265
Parameters
264266
----------
265267
col_name : Hashable

pandas/core/reshape/tile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def cut(
108108
The precision at which to store and display the bins labels.
109109
include_lowest : bool, default False
110110
Whether the first interval should be left-inclusive or not.
111-
duplicates : {default 'raise', 'drop'}, optional
111+
duplicates : {'raise', 'drop'}, default 'raise'
112112
If bin edges are not unique, raise ValueError or drop non-uniques.
113113
ordered : bool, default True
114114
Whether the labels are ordered or not. Applies to returned types

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ gitpython
6161
natsort
6262
pickleshare
6363
numpydoc
64-
pydata-sphinx-theme==0.16
6564
pytest-cython
6665
sphinx
6766
sphinx-design
@@ -87,3 +86,4 @@ pygments
8786
jupyterlite-core
8887
jupyterlite-pyodide-kernel
8988
tzdata>=2023.3
89+
https://github.com/jorisvandenbossche/pydata-sphinx-theme/archive/refs/heads/v0.16.1+dismissable-announcement-banner.zip

web/pandas/_templates/layout.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@
5656
</nav>
5757
</header>
5858
<main role="main">
59-
<div class="container">
59+
{% block body_container %}
60+
<div class="container container-main">
6061
{% block body %}{% endblock %}
6162
</div>
63+
{% endblock %}
6264
</main>
6365
<footer class="container pt-4 pt-md-5 border-top">
6466
<ul class="list-inline social-buttons float-end">
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
Title: pandas 3.0.0 release candidate ready for testing!
2+
Date: 2025-12-12
3+
4+
# pandas 3.0.0 release candidate ready for testing!
5+
6+
We're excited to announce the release candidate for pandas 3.0. This major
7+
release brings significant improvements to pandas, but also features some
8+
potentially breaking changes.
9+
10+
To ensure a smooth pandas 3.0 release, we can use your help to [test the
11+
release candidate now](#call-to-action-test-the-release-candidate).
12+
13+
## Highlights of pandas 3.0
14+
15+
pandas 3.0 introduces several major enhancements:
16+
17+
- **Dedicated string data type by default**: string columns are now inferred as
18+
the new `str` dtype instead of `object`, providing better performance and type
19+
safety
20+
- **Consistent copy/view behaviour with Copy-on-Write (CoW)** (a.k.a. getting
21+
rid of the SettingWithCopyWarning): more predictable and consistent behavior
22+
for all operations, with improved performance through avoiding unnecessary
23+
copies
24+
- **New `pd.col` syntax**: initial support for `pd.col()` as a simplified syntax
25+
for creating callables in `DataFrame.assign`
26+
27+
Further, pandas 3.0 includes a lot of other improvements and bug fixes. You can
28+
find the complete list of changes in our
29+
[release notes](https://pandas.pydata.org/docs/dev/whatsnew/v3.0.0.html).
30+
31+
## Important changes requiring code updates
32+
33+
As a major release, pandas 3.0 includes some breaking changes that may require
34+
updates to your code. The two most significant changes are:
35+
36+
### 1. Dedicated string data type by default
37+
38+
Starting with pandas 3.0, string columns are automatically inferred as `str`
39+
dtype instead of the numpy `object` (which can store any Python object).
40+
41+
**Example:**
42+
```python
43+
# Old behavior (pandas < 3.0)
44+
>>> ser = pd.Series(["a", "b"])
45+
>>> ser
46+
0 a
47+
1 b
48+
dtype: object # <-- numpy object dtype
49+
50+
# New behavior (pandas 3.0)
51+
>>> ser = pd.Series(["a", "b"])
52+
>>> ser.dtype
53+
>>> ser
54+
0 a
55+
1 b
56+
dtype: str # <-- new string dtype
57+
```
58+
59+
This change improves performance and type safety, but may require code updates,
60+
especially for library code that currently looks for "object" dtype when
61+
expecting string data.
62+
63+
For more details, see the
64+
[migration guide for the new string data type](https://pandas.pydata.org/docs/dev/user_guide/migration-3-strings.html).
65+
66+
### 2. Consistent copy/view behaviour with Copy-on-Write (CoW)
67+
68+
Copy-on-Write is now the default and only mode in pandas 3.0. This makes
69+
behavior more consistent and predictable, but requires updates to certain coding
70+
patterns.
71+
72+
The most impactfull change is that **chained assignment will no longer work**.
73+
As a result, the `SettingWithCopyWarning` is also removed (since there is no
74+
longer ambiguity whether it would work or not), and defensive `.copy()` calls
75+
to silence the warning are no longer needed.
76+
77+
**Example:**
78+
```python
79+
# Old behavior (pandas < 3.0) - chained assignment
80+
df["foo"][df["bar"] > 5] = # This might modify df (unpredictable)
81+
82+
# New behavior (pandas 3.0) - must do the modification in one step (e.g. with .loc)
83+
df.loc[df["bar"] > 5, "foo"] = 100
84+
```
85+
86+
In general, any result of an indexing operation or method now always behaves as
87+
if it were a copy, so modifications of the result won't affect the original
88+
DataFrame.
89+
90+
For more details, see the
91+
[Copy-on-Write migration guide](https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html#migrating-to-copy-on-write).
92+
93+
94+
## Call to Action: test the Release Candidate
95+
96+
We need your help to ensure a smooth pandas 3.0 release!
97+
98+
Especially if you have pandas code in production or maintain a library with
99+
pandas as a dependency, it is strongly recommended to run your test suites with
100+
the release candidate, and report any issue to our issue tracker before the
101+
official 3.0.0 release.
102+
103+
How can you best test the release candidate?
104+
105+
1. **First update to the latest released pandas 2.3** (if you are not already
106+
running that version) and test it with your codebase. It is recommended to
107+
resolve any deprecation warning before upgrading to pandas 3.0.
108+
2. Optionally, you can already enable the new string dtype and Copy-on-Write
109+
mode using pandas 2.3 (`pd.options.future.infer_string = True` and
110+
`pd.options.mode.copy_on_write = True`).
111+
3. **Install the release candidate** (see below) and test it with your codebase
112+
4. **Run your existing code** to identify any issues or needed updates
113+
5. **Report any problems** you encounter on our [GitHub repository issue tracker](https://github.com/pandas-dev/pandas/issues)
114+
115+
The more testing we get now, the smoother the final pandas 3.0 release will be
116+
for everyone. Your feedback is crucial for making this a successful release!
117+
118+
### Getting the Release Candidate
119+
120+
You can install the pandas 3.0 release candidate from PyPI:
121+
122+
```bash
123+
python -m pip install --upgrade pandas==3.0.0rc0
124+
```
125+
126+
Or from conda-forge using conda/mamba:
127+
128+
```bash
129+
conda install -c conda-forge/label/pandas_rc pandas==3.0.0rc0
130+
```

web/pandas/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "layout.html" %}
2-
{% block body %}
2+
{% block body_container %}
33
<div class="container">
44
<div class="row">
55
<div class="col-md-9">

0 commit comments

Comments
 (0)