Skip to content

Commit d49fcd8

Browse files
committed
TST: Add test to ensure Dataframe describe does not throw an error (pandas-dev#32409)
1 parent 37662ea commit d49fcd8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pandas/tests/frame/methods/test_describe.py

+24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
import pytest
23

34
import pandas as pd
45
from pandas import Categorical, DataFrame, Series, Timestamp, date_range
@@ -298,3 +299,26 @@ def test_describe_percentiles_integer_idx(self):
298299
],
299300
)
300301
tm.assert_frame_equal(result, expected)
302+
303+
def test_describe_does_not_raise_error(self):
304+
# GH#32409
305+
df = pd.DataFrame(
306+
[{"test": {"a": "1"}}, {"test": {"a": "2"}}]
307+
)
308+
expected = DataFrame(
309+
{"test": [2, 2, {'a': '1'}, 1]},
310+
index=["count", "unique", "top", "freq"]
311+
)
312+
try:
313+
result = df.describe()
314+
tm.assert_frame_equal(result, expected)
315+
exp_repr = (
316+
" test\n"
317+
"count 2\n"
318+
"unique 2\n"
319+
"top {'a': '1'}\n"
320+
"freq 1"
321+
)
322+
assert repr(result) == exp_repr
323+
except TypeError as e:
324+
pytest.fail(f'TypeError was raised {e}')

0 commit comments

Comments
 (0)