Skip to content

Commit 0e69f9e

Browse files
committed
Merge pull request #8449 from jreback/cat
BUG: bug in df.info() when embedded categorical (related GH7619)
2 parents 977034a + 8a90c7b commit 0e69f9e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pandas/core/internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def apply(self, func, **kwargs):
245245
""" apply the function to my values; return a block if we are not one """
246246
result = func(self.values)
247247
if not isinstance(result, Block):
248-
result = make_block(values=result, placement=self.mgr_locs,)
248+
result = make_block(values=_block_shape(result), placement=self.mgr_locs,)
249249

250250
return result
251251

pandas/tests/test_categorical.py

+12
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,18 @@ def test_repr(self):
13061306
self.assertEqual(exp,a.__unicode__())
13071307

13081308

1309+
def test_info(self):
1310+
1311+
# make sure it works
1312+
n = 2500
1313+
df = DataFrame({ 'int64' : np.random.randint(100,size=n) })
1314+
df['category'] = Series(np.array(list('abcdefghij')).take(np.random.randint(0,10,size=n))).astype('category')
1315+
df.isnull()
1316+
df.info()
1317+
1318+
df2 = df[df['category']=='d']
1319+
df2.info()
1320+
13091321
def test_groupby_sort(self):
13101322

13111323
# http://stackoverflow.com/questions/23814368/sorting-pandas-categorical-labels-after-groupby

0 commit comments

Comments
 (0)