Skip to content

Commit 10fbdb9

Browse files
updated generic.py to_json method to raise ValueError if the column types are not string
1 parent 6bcd303 commit 10fbdb9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/core/generic.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,6 +2584,14 @@ def to_json(
25842584
]
25852585
}}
25862586
"""
2587+
2588+
if orient == "table":
2589+
if any(isinstance(col, (int, float)) for col in self.columns):
2590+
raise ValueError(
2591+
"Column names must be strings for JSON serialization with "
2592+
"orient='table'."
2593+
)
2594+
25872595
from pandas.io import json
25882596

25892597
if date_format is None and orient == "table":

0 commit comments

Comments
 (0)