Closed
Description
it would be nice to have number in front of all labels. put number like 00, 01, 02 in front of labels so that it would order appropriately.
Lib\site-packages\pandas\tools\tile.py
def _format_levels(bins, prec, right=True,
include_lowest=False):
fmt = lambda v: _format_label(v, precision=prec)
cnter=0
if right:
levels = []
for a, b in zip(bins, bins[1:]):
fa, fb = fmt(a), fmt(b)
if a != b and fa == fb:
raise ValueError('precision too low')
formatted = '%02d: (%s, %s]' % (cnter, fa, fb)
cnter=cnter +1
levels.append(formatted)
if include_lowest:
levels[0] = '[' + levels[0][1:]
else:
levels = ['[%s, %s)' % (fmt(a), fmt(b))
for a, b in zip(bins, bins[1:])]
return levels
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
jreback commentedon Oct 21, 2014
this is going to be turned into a Categorical, so ordering will happen automatically. interested to do for 0.15.1?
jreback commentedon Oct 21, 2014
@fancychildren can you post a full example (that doesn't order correctly)
fancychildren commentedon Oct 21, 2014
here is the example. after i create the cuts and apply summary to the dataframe, the currLoanSize bucket is ordered as if it's a string, instead of a number of the lower boundary.
after i tweak the code, it appears like this

not sure if i am not using it correctly. but i would be nice to be able to order by the value of lower boundary, while keeping the label.
jreback commentedon Oct 21, 2014
can you do a programatic example, e.g.
df = DataFrame.......
eventually we'll turn this into a testfancychildren commentedon Oct 21, 2014
[-]pandas\tools\title.py[/-][+]API: cut interval formatting[/+]10 remaining items