Skip to content

cannot get cut() to display desired bins label #15357

Open
@qAp

Description

@qAp

srs1 are some 1000 random numbers to be binned using the boundaries in absths:

srs1 = pd.Series(np.random.uniform(low=0, high=3e-17, size=(1000,)))
absths = np.array([0., 1.e-22, 1.e-18, 1.e-16])

Bin them, print out the boundaries, and the results for the first 5 numbers in srs1:

ncut1 = pd.cut(srs1, 
              bins=absths, 
              include_lowest=True, 
              precision=16,
              retbins=True)

print(ncut1[1])
print(ncut1[0][:5])

gives

[  0.00000000e+00   1.00000000e-22   1.00000000e-18   1.00000000e-16]
0    (1.0000000000000001e-18, 9.9999999999999998e-17]
1    (1.0000000000000001e-18, 9.9999999999999998e-17]
2    (1.0000000000000001e-18, 9.9999999999999998e-17]
3    (1.0000000000000001e-18, 9.9999999999999998e-17]
4    (1.0000000000000001e-18, 9.9999999999999998e-17]
dtype: category
Categories (3, object): [[0, 1] < (1, 1.0000000000000001e-18] < (1.0000000000000001e-18, 9.9999999999999998e-17]]

The boundary that is meant to be 1e-22 is displayed as 1 in Categories. The keyword argument precision is already set to 16 to display many decimals. Is this a bug or am I not using the function correctly?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsNumeric OperationsArithmetic, Comparison, and Logical operationscutcut, qcut

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions