Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
BUG: pandas.cut and negative values #14652
Here is an example of pandas.cut ran on a pandas.Series with only one positive element and then on a pandas.Series with only one negative element. In the second scenario pandas.cut is not able to insert the single value on the only one bin.
I might be wrong but I expected pandas.cut to behave on negative values the same as with positive
A small, complete example of the issue
import pandas as pd import numpy as np >>> s = pd.Series([1.]) >>> pd.cut(s, 1) 0 (0.999, 1.001] dtype: category Categories (1, object): [(0.999, 1.001]] >>> s = pd.Series([-1.]) >>> pd.cut(s, 1) 0 NaN dtype: category Categories (1, object): [(-0.999, -1.001]]