Supose I have the following DataFrame:
Area
0 14.68
1 40.54
2 10.82
3 2.31
4 22.3
And I want to categorize that values in range. Like A: [1,10], B: [11,20], C...
Area
0 B
1 D
2 C
3 A
4 C
How can I do it with Pandas? I tried following code:
bins = pd.IntervalIndex.from_tuples([(0, 11), (11, 20), (20, 50), (50, 100), (100, 500), (500, np.max(df["area"]) + 1)], closed='left')
catDf = pd.cut(df["area"], bins = bins)
But "cut" command just put range values in DataFrame and I want put the categories names instead of range.
EDIT: I tried to pass label to the cut, but nothing changes. EDIT2: To clarify, if the value of "area" have 10.21, so it's in range of [10,20], so it must be labeled like "B" or other label for that range of values.