File tree 3 files changed +23
-5
lines changed
3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 1
1
from .pandas_vb_common import *
2
2
import string
3
3
4
+
4
5
class concat_categorical (object ):
5
6
goal_time = 0.2
6
7
@@ -26,6 +27,7 @@ def time_value_counts(self):
26
27
def time_value_counts_dropna (self ):
27
28
self .ts .value_counts (dropna = True )
28
29
30
+
29
31
class categorical_constructor (object ):
30
32
goal_time = 0.2
31
33
@@ -43,3 +45,16 @@ def time_regular_constructor(self):
43
45
def time_fastpath (self ):
44
46
Categorical (self .codes , self .cat_idx , fastpath = True )
45
47
48
+
49
+ class categorical_rendering (object ):
50
+ goal_time = 3e-3
51
+
52
+ def setup (self ):
53
+ n = 1000
54
+ items = [str (i ) for i in range (n )]
55
+ s = pd .Series (items , dtype = 'category' )
56
+ df = pd .DataFrame ({'C' : s , 'data' : np .random .randn (n )})
57
+ self .data = df [df .C == '20' ]
58
+
59
+ def time_rendering (self ):
60
+ str (self .data .C )
Original file line number Diff line number Diff line change 3
3
v0.17.1 (November ??, 2015)
4
4
---------------------------
5
5
6
- This is a minor bug-fix release from 0.17.0 and includes a a large number of
6
+ This is a minor bug-fix release from 0.17.0 and includes a large number of
7
7
bug fixes along several new features, enhancements, and performance improvements.
8
8
We recommend that all users upgrade to this version.
9
9
@@ -64,9 +64,11 @@ Performance Improvements
64
64
- Improved performance of ``rolling_median`` (:issue:`11450`)
65
65
66
66
- Improved performance to ``to_excel`` (:issue:`11352`)
67
+ - Performance bug in repr of ``Categorical`` categories, which was rendering the strings before chopping them for display (:issue:`11305`)
67
68
68
69
.. _whatsnew_0171.bug_fixes:
69
70
71
+
70
72
Bug Fixes
71
73
~~~~~~~~~
72
74
Original file line number Diff line number Diff line change @@ -1390,12 +1390,13 @@ def _repr_categories(self):
1390
1390
max_categories = (10 if get_option ("display.max_categories" ) == 0
1391
1391
else get_option ("display.max_categories" ))
1392
1392
from pandas .core import format as fmt
1393
- category_strs = fmt .format_array (self .categories , None )
1394
- if len (category_strs ) > max_categories :
1393
+ if len (self .categories ) > max_categories :
1395
1394
num = max_categories // 2
1396
- head = category_strs [:num ]
1397
- tail = category_strs [ - ( max_categories - num ):]
1395
+ head = fmt . format_array ( self . categories [:num ], None )
1396
+ tail = fmt . format_array ( self . categories [ - num :], None )
1398
1397
category_strs = head + ["..." ] + tail
1398
+ else :
1399
+ category_strs = fmt .format_array (self .categories , None )
1399
1400
1400
1401
# Strip all leading spaces, which format_array adds for columns...
1401
1402
category_strs = [x .strip () for x in category_strs ]
You can’t perform that action at this time.
0 commit comments