Code Sample, a copy-pastable example if possible
ages = [20, 22, 25, 27, 21, 23, 37, 31, 61, 45, 41, 32]
bins = [18, 25, 35, 60, 100]
cats = pd.cut(ages, bins)
print(repr(cats))
Problem description
This outputs
[(18, 25], (18, 25], (18, 25], (25, 35], (18, 25], ..., (25, 35], (60, 100], (35, 60], (35, 60], (25, 35]]
Length: 12
Categories (4, object): [(18, 25] < (25, 35] < (35, 60] < (60, 100]]
The first line has 106 characters. This is a bad user experience for shell users with 80-character-wide terminals
Expected Output
in the first line
[(18, 25], (18, 25], (18, 25], (25, 35], (18, 25], ...,
(25, 35], (60, 100], (35, 60], (35, 60], (25, 35]]
or
[(18, 25], (18, 25], (18, 25], ..., (35, 60], (35, 60], (25, 35]]
Output of pd.show_versions()
pandas 0.19.2
Comment From: wesm
The categories output spills over too
In [22]: data = np.random.randn(1000)
In [23]: pd.qcut(data, [0, 0.1, 0.5, 0.9, 1.])
Out[23]:
[(-1.245, 0.0321], (-1.245, 0.0321], (-1.245, 0.0321], (-1.245, 0.0321], (-1.245, 0.0321], ..., (0.0321, 1.286], (-1.245, 0.0321], (0.0321, 1.286], (0.0321, 1.286], (0.0321, 1.286]]
Length: 1000
Categories (4, object): [[-3.285, -1.245] < (-1.245, 0.0321] < (0.0321, 1.286] < (1.286, 3.117]]
Comment From: jreback
dupe of #12066
Comment From: wesm
Funny. Thanks