Skip to content

Commit 7cc3b41

Browse files
committed
Merge branch 'main' into api-nan-vs-na
2 parents 1bb0a4e + 188b2da commit 7cc3b41

Some content is hidden

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

41 files changed

+803
-663
lines changed

doc/redirects.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,6 @@ generated/pandas.Index.get_slice_bound,../reference/api/pandas.Index.get_slice_b
643643
generated/pandas.Index.groupby,../reference/api/pandas.Index.groupby
644644
generated/pandas.Index.has_duplicates,../reference/api/pandas.Index.has_duplicates
645645
generated/pandas.Index.hasnans,../reference/api/pandas.Index.hasnans
646-
generated/pandas.Index.holds_integer,../reference/api/pandas.Index.holds_integer
647646
generated/pandas.Index,../reference/api/pandas.Index
648647
generated/pandas.Index.identical,../reference/api/pandas.Index.identical
649648
generated/pandas.Index.inferred_type,../reference/api/pandas.Index.inferred_type

doc/source/index.rst.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ programming language.
113113
:titlesonly:
114114

115115
{{ single_doc[:-4] }}
116-
{% elif single_doc and single_doc.count('.') <= 1 %}
116+
{% elif single_doc and ((single_doc.count('.') <= 1) or ('tseries' in single_doc)) -%}
117117
.. autosummary::
118118
:toctree: reference/api/
119119

doc/source/reference/general_functions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Top-level evaluation
7171
.. autosummary::
7272
:toctree: api/
7373

74+
col
7475
eval
7576

7677
Datetime formats

doc/source/user_guide/dsintro.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,12 @@ a function of one argument to be evaluated on the DataFrame being assigned to.
553553
554554
iris.assign(sepal_ratio=lambda x: (x["SepalWidth"] / x["SepalLength"])).head()
555555
556+
or, using :meth:`pandas.col`:
557+
558+
.. ipython:: python
559+
560+
iris.assign(sepal_ratio=pd.col("SepalWidth") / pd.col("SepalLength")).head()
561+
556562
:meth:`~pandas.DataFrame.assign` **always** returns a copy of the data, leaving the original
557563
DataFrame untouched.
558564

doc/source/whatsnew/v2.3.1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ Bug fixes
7373
Contributors
7474
~~~~~~~~~~~~
7575

76-
.. contributors:: v2.3.0..v2.3.1|HEAD
76+
.. contributors:: v2.3.0..v2.3.1

doc/source/whatsnew/v2.3.2.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.. _whatsnew_232:
22

3-
What's new in 2.3.2 (August XX, 2025)
3+
What's new in 2.3.2 (August 21, 2025)
44
-------------------------------------
55

66
These are the changes in pandas 2.3.2. See :ref:`release` for a full changelog
@@ -36,3 +36,5 @@ Bug fixes
3636

3737
Contributors
3838
~~~~~~~~~~~~
39+
40+
.. contributors:: v2.3.1..v2.3.2|HEAD

doc/source/whatsnew/v3.0.0.rst

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,28 @@ 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-
.. _whatsnew_300.enhancements.enhancement2:
120+
.. _whatsnew_300.enhancements.col:
121121

122-
Enhancement2
123-
^^^^^^^^^^^^
122+
``pd.col`` syntax can now be used in :meth:`DataFrame.assign` and :meth:`DataFrame.loc`
123+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
124+
125+
You can now use ``pd.col`` to create callables for use in dataframe methods which accept them. For example, if you have a dataframe
126+
127+
.. ipython:: python
128+
129+
df = pd.DataFrame({'a': [1, 1, 2], 'b': [4, 5, 6]})
130+
131+
and you want to create a new column ``'c'`` by summing ``'a'`` and ``'b'``, then instead of
132+
133+
.. ipython:: python
134+
135+
df.assign(c = lambda df: df['a'] + df['b'])
136+
137+
you can now write:
138+
139+
.. ipython:: python
140+
141+
df.assign(c = pd.col('a') + pd.col('b'))
124142
125143
New Deprecation Policy
126144
^^^^^^^^^^^^^^^^^^^^^^

pandas/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
Series,
106106
DataFrame,
107107
)
108+
from pandas.core.col import col
108109

109110
from pandas.core.dtypes.dtypes import SparseDtype
110111

@@ -281,6 +282,7 @@
281282
"array",
282283
"arrays",
283284
"bdate_range",
285+
"col",
284286
"concat",
285287
"crosstab",
286288
"cut",

pandas/_libs/tslibs/offsets.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,12 @@ class YearOffset(SingleConstructorOffset):
156156

157157
class BYearEnd(YearOffset): ...
158158
class BYearBegin(YearOffset): ...
159-
class YearEnd(YearOffset): ...
159+
160+
class YearEnd(YearOffset):
161+
def __new__(
162+
cls, n: int = ..., normalize: bool = ..., month: int | None = ...
163+
) -> Self: ...
164+
160165
class YearBegin(YearOffset): ...
161166

162167
class QuarterOffset(SingleConstructorOffset):

pandas/_libs/tslibs/offsets.pyx

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,14 +2737,31 @@ cdef class BYearBegin(YearOffset):
27372737
_prefix = "BYS"
27382738
_day_opt = "business_start"
27392739

2740+
# The pair of classes `_YearEnd` and `YearEnd` exist because of
2741+
# https://github.com/cython/cython/issues/3873
27402742

2741-
cdef class YearEnd(YearOffset):
2743+
cdef class _YearEnd(YearOffset):
2744+
_default_month = 12
2745+
_prefix = "YE"
2746+
_day_opt = "end"
2747+
2748+
cdef readonly:
2749+
int _period_dtype_code
2750+
2751+
def __init__(self, n=1, normalize=False, month=None):
2752+
# Because YearEnd can be the freq for a Period, define its
2753+
# _period_dtype_code at construction for performance
2754+
YearOffset.__init__(self, n, normalize, month)
2755+
self._period_dtype_code = PeriodDtypeCode.A + self.month % 12
2756+
2757+
2758+
class YearEnd(_YearEnd):
27422759
"""
27432760
DateOffset increments between calendar year end dates.
27442761
27452762
YearEnd goes to the next date which is the end of the year.
27462763
2747-
Attributes
2764+
Parameters
27482765
----------
27492766
n : int, default 1
27502767
The number of years represented.
@@ -2778,18 +2795,8 @@ cdef class YearEnd(YearOffset):
27782795
Timestamp('2022-12-31 00:00:00')
27792796
"""
27802797

2781-
_default_month = 12
2782-
_prefix = "YE"
2783-
_day_opt = "end"
2784-
2785-
cdef readonly:
2786-
int _period_dtype_code
2787-
2788-
def __init__(self, n=1, normalize=False, month=None):
2789-
# Because YearEnd can be the freq for a Period, define its
2790-
# _period_dtype_code at construction for performance
2791-
YearOffset.__init__(self, n, normalize, month)
2792-
self._period_dtype_code = PeriodDtypeCode.A + self.month % 12
2798+
def __new__(cls, n=1, normalize=False, month=None):
2799+
return _YearEnd.__new__(cls, n, normalize, month)
27932800

27942801

27952802
cdef class YearBegin(YearOffset):
@@ -5188,8 +5195,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str:
51885195
warnings.warn(
51895196
f"\'{name}\' is deprecated and will be removed "
51905197
f"in a future version, please use "
5191-
f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name)}\'"
5192-
f" instead.",
5198+
f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name)}\' "
5199+
f"instead.",
51935200
FutureWarning,
51945201
stacklevel=find_stack_level(),
51955202
)
@@ -5202,8 +5209,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str:
52025209
warnings.warn(
52035210
f"\'{name}\' is deprecated and will be removed "
52045211
f"in a future version, please use "
5205-
f"\'{_name}\'"
5206-
f" instead.",
5212+
f"\'{_name}\' "
5213+
f"instead.",
52075214
FutureWarning,
52085215
stacklevel=find_stack_level(),
52095216
)

0 commit comments

Comments
 (0)