Python: pandas.cut labels are ignored
问题 I want to cut one column in my pandas.DataFrame using pandas.cut(), but the labels I put into labels argument are not applied. Let me show you an example. I have got the following data frame: >>> import pandas as pd >>> df = pd.DataFrame({'x': [-0.009, 0.089, 0.095, 0.096, 0.198]}) >>> print(df) x 0 -0.009 1 0.089 2 0.095 3 0.096 4 0.198 And I cut x column like this: >>> bins = pd.IntervalIndex.from_tuples([(-0.2, -0.1), (-0.1, 0.0), (0.0, 0.1), (0.1, 0.2)]) >>> labels = [100, 200, 300, 400]