Skip to content

Commit 4be0ee8

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

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
@@ -360,3 +361,26 @@ def test_describe_percentiles_integer_idx(self):
360361
],
361362
)
362363
tm.assert_frame_equal(result, expected)
364+
365+
def test_describe_does_not_raise_error(self):
366+
# GH#32409
367+
df = pd.DataFrame(
368+
[{"test": {"a": "1"}}, {"test": {"a": "2"}}]
369+
)
370+
expected = DataFrame(
371+
{"test": [2, 2, {'a': '1'}, 1]},
372+
index=["count", "unique", "top", "freq"]
373+
)
374+
try:
375+
result = df.describe()
376+
tm.assert_frame_equal(result, expected)
377+
exp_repr = (
378+
" test\n"
379+
"count 2\n"
380+
"unique 2\n"
381+
"top {'a': '1'}\n"
382+
"freq 1"
383+
)
384+
assert repr(result) == exp_repr
385+
except TypeError as e:
386+
pytest.fail(f'TypeError was raised {e}')

0 commit comments

Comments
 (0)