Skip to content

Commit 25e7e84

Browse files
committed
Add unit tests and whatsnew info
1 parent 167bfe2 commit 25e7e84

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ I/O
749749
- Bug in :meth:`read_stata` where the missing code for double was not recognised for format versions 105 and prior (:issue:`58149`)
750750
- Bug in :meth:`set_option` where setting the pandas option ``display.html.use_mathjax`` to ``False`` has no effect (:issue:`59884`)
751751
- Bug in :meth:`to_excel` where :class:`MultiIndex` columns would be merged to a single row when ``merge_cells=False`` is passed (:issue:`60274`)
752+
- Bug in :meth:`to_json` raising ``OverflowError`` when convert DataFrame.dtypes Series to JSON (:issue:`61170`)
752753

753754
Period
754755
^^^^^^

pandas/_libs/src/vendored/ujson/python/ujson.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ int object_is_na_type(PyObject *obj) {
212212
return result;
213213
}
214214

215-
int object_is_ndtypes_type(PyObject * obj){
216-
PyObject * ndtype = (PyObject*)&PyArrayDescr_Type;
215+
int object_is_ndtypes_type(PyObject *obj) {
216+
PyObject *ndtype = (PyObject *)&PyArrayDescr_Type;
217217
int result = PyObject_IsInstance(obj, ndtype);
218218
if (result == -1) {
219219
PyErr_Clear();

pandas/tests/io/json/test_pandas.py

+16
Original file line numberDiff line numberDiff line change
@@ -2311,3 +2311,19 @@ def test_large_number():
23112311
)
23122312
expected = Series([9999999999999999])
23132313
tm.assert_series_equal(result, expected)
2314+
2315+
2316+
@pytest.mark.parametrize(
2317+
"dataframe, expected_json",
2318+
[
2319+
(DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}), '{"A":"int64","B":"int64"}'),
2320+
(
2321+
DataFrame({"X": [1.1, 2.2], "Y": ["a", "b"]}),
2322+
'{"X":"float64","Y":"object"}',
2323+
),
2324+
],
2325+
)
2326+
def test_dtypes_to_json(dataframe: DataFrame, expected_json):
2327+
# GH 61170
2328+
dtypes_json = dataframe.dtypes.to_json()
2329+
assert json.loads(dtypes_json) == json.loads(expected_json)

0 commit comments

Comments
 (0)