Skip to content

Commit

Permalink
TST: Add test to ensure Dataframe describe does not throw an error (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyvs1 committed Jul 14, 2020
1 parent 37662ea commit d49fcd8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pandas/tests/frame/methods/test_describe.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import pytest

import pandas as pd
from pandas import Categorical, DataFrame, Series, Timestamp, date_range
Expand Down Expand Up @@ -298,3 +299,26 @@ def test_describe_percentiles_integer_idx(self):
],
)
tm.assert_frame_equal(result, expected)

def test_describe_does_not_raise_error(self):
# GH#32409
df = pd.DataFrame(
[{"test": {"a": "1"}}, {"test": {"a": "2"}}]
)
expected = DataFrame(
{"test": [2, 2, {'a': '1'}, 1]},
index=["count", "unique", "top", "freq"]
)
try:
result = df.describe()
tm.assert_frame_equal(result, expected)
exp_repr = (
" test\n"
"count 2\n"
"unique 2\n"
"top {'a': '1'}\n"
"freq 1"
)
assert repr(result) == exp_repr
except TypeError as e:
pytest.fail(f'TypeError was raised {e}')

0 comments on commit d49fcd8

Please sign in to comment.