diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index 2013f81d4da18..8e696f5f8f22e 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -54,6 +54,7 @@ Other enhancements - :meth:`Series.cummin` and :meth:`Series.cummax` now supports :class:`CategoricalDtype` (:issue:`52335`) - :meth:`Series.plot` now correctly handle the ``ylabel`` parameter for pie charts, allowing for explicit control over the y-axis label (:issue:`58239`) - :meth:`DataFrame.plot.scatter` argument ``c`` now accepts a column of strings, where rows with the same string are colored identically (:issue:`16827` and :issue:`16485`) +- :func:`DataFrame.query` can now deal with integer column names (:issue:`60494`) - :func:`read_parquet` accepts ``to_pandas_kwargs`` which are forwarded to :meth:`pyarrow.Table.to_pandas` which enables passing additional keywords to customize the conversion to pandas, such as ``maps_as_pydicts`` to read the Parquet map data type as python dictionaries (:issue:`56842`) - :meth:`DataFrameGroupBy.transform`, :meth:`SeriesGroupBy.transform`, :meth:`DataFrameGroupBy.agg`, :meth:`SeriesGroupBy.agg`, :meth:`RollingGroupby.apply`, :meth:`ExpandingGroupby.apply`, :meth:`Rolling.apply`, :meth:`Expanding.apply`, :meth:`DataFrame.apply` with ``engine="numba"`` now supports positional arguments passed as kwargs (:issue:`58995`) - :meth:`Series.map` can now accept kwargs to pass on to func (:issue:`59814`) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index d1aa20501b060..c543151b0260a 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -606,7 +606,6 @@ def _get_cleaned_column_resolvers(self) -> dict[Hashable, Series]: v, copy=False, index=self.index, name=k, dtype=dtype ).__finalize__(self) for k, v, dtype in zip(self.columns, self._iter_column_arrays(), dtypes) - if not isinstance(k, int) } @final diff --git a/pandas/tests/frame/test_query_eval.py b/pandas/tests/frame/test_query_eval.py index ca572b1026526..35c1708135fa8 100644 --- a/pandas/tests/frame/test_query_eval.py +++ b/pandas/tests/frame/test_query_eval.py @@ -1326,6 +1326,11 @@ def test_unneeded_quoting(self, df): expect = df[df["A"] > 2] tm.assert_frame_equal(res, expect) + def test_quoting_with_ints(self, df): + res = df.query("`1` > 5") + expect = df[df[1] > 5] + tm.assert_frame_equal(res, expect) + def test_parenthesis(self, df): res = df.query("`A (x)` > 2") expect = df[df["A (x)"] > 2]