Skip to content

Commit 62483d7

Browse files
added change to whatsnew doc and also changed the logic to raise the ValueError only if its a Dataframe and not for a Series
1 parent f91125c commit 62483d7

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Other enhancements
6565
- :class:`Rolling` and :class:`Expanding` now support aggregations ``first`` and ``last`` (:issue:`33155`)
6666
- :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`)
6767
- :meth:`.DataFrameGroupBy.transform`, :meth:`.SeriesGroupBy.transform`, :meth:`.DataFrameGroupBy.agg`, :meth:`.SeriesGroupBy.agg`, :meth:`.SeriesGroupBy.apply`, :meth:`.DataFrameGroupBy.apply` now support ``kurt`` (:issue:`40139`)
68+
- :meth:`DataFrame.to_json` with ``orient="table"`` now raises a ``ValueError`` if column names are not strings (:issue:`19129`).
6869
- :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`)
6970
- :meth:`Rolling.agg`, :meth:`Expanding.agg` and :meth:`ExponentialMovingWindow.agg` now accept :class:`NamedAgg` aggregations through ``**kwargs`` (:issue:`28333`)
7071
- :meth:`Series.map` can now accept kwargs to pass on to func (:issue:`59814`)

pandas/core/generic.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2593,7 +2593,9 @@ def to_json(
25932593
"""
25942594

25952595
if orient == "table":
2596-
if any(isinstance(col, (int, float)) for col in self.columns):
2596+
if hasattr(self, "columns") and any(
2597+
isinstance(col, (int, float)) for col in self.columns
2598+
):
25972599
raise ValueError(
25982600
"Column names must be strings for JSON serialization with "
25992601
"orient='table'."

0 commit comments

Comments
 (0)