Skip to content

Commit 18e6155

Browse files
committed
TST: Test describe method of Categorical
1 parent 4b45f7a commit 18e6155

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/test_factor.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from pandas.core.api import value_counts
1010
from pandas.core.categorical import Categorical
1111
from pandas.core.index import Index, Int64Index, MultiIndex
12+
from pandas.core.frame import DataFrame
1213
from pandas.util.testing import assert_almost_equal
1314
import pandas.core.common as com
1415

@@ -116,6 +117,23 @@ def test_levels_none(self):
116117
'a', 'c', 'c', 'c'])
117118
self.assert_(factor.equals(self.factor))
118119

120+
def test_describe(self):
121+
# string type
122+
desc = self.factor.describe()
123+
expected = DataFrame.from_dict(dict(counts=[3, 2, 3],
124+
freqs=[3/8., 2/8., 3/8.],
125+
levels=['a', 'b', 'c'])
126+
).set_index('levels')
127+
tm.assert_frame_equal(desc, expected)
128+
129+
# check an integer one
130+
desc = Categorical([1,2,3,1,2,3,3,2,1,1,1]).describe()
131+
expected = DataFrame.from_dict(dict(counts=[5, 3, 3],
132+
freqs=[5/11., 3/11., 3/11.],
133+
levels=[1,2,3]
134+
)
135+
).set_index('levels')
136+
tm.assert_frame_equal(desc, expected)
119137

120138
if __name__ == '__main__':
121139
import nose

0 commit comments

Comments
 (0)