Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pandas.cut crashes on all zero input #8309

Closed
RasterBurn opened this issue Sep 18, 2014 · 2 comments
Closed

pandas.cut crashes on all zero input #8309

RasterBurn opened this issue Sep 18, 2014 · 2 comments
Labels
Duplicate Report Duplicate issue or pull request Error Reporting Incorrect or improved errors from pandas Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@RasterBurn
Copy link

xref #7751

import pandas as pd
pd.cut([0,0,0,0], 10)

result:

ValueError: Bin edges must be unique: array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.])

On the other hand, pandas.cut works on non-unique inputs other than zero. The culprit are the following lines of code in tile.py:

        if mn == mx:  # adjust end points before binning
            mn -= .001 * mn
            mx += .001 * mx
            bins = np.linspace(mn, mx, bins + 1, endpoint=True)

When mn and mx are zero, the adjustment isn't made.


>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.32-300.3.1.el6uek.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.14.1
nose: 1.3.1
Cython: None
numpy: 1.9.0
scipy: 0.14.0
statsmodels: None
IPython: 2.0.0
sphinx: None
patsy: None
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.4
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.3.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
rpy2: 2.4.2
sqlalchemy: None
pymysql: None
psycopg2: None
@jreback
Copy link
Contributor

jreback commented Sep 18, 2014

dupe of this issue: #7751

wouldn't you as a user want to know this?

@jreback jreback added Duplicate Report Duplicate issue or pull request Error Reporting Incorrect or improved errors from pandas Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Sep 18, 2014
@jreback jreback added this to the 0.15.1 milestone Sep 18, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@TomAugspurger
Copy link
Contributor

Closed by 8051d61

@TomAugspurger TomAugspurger modified the milestones: Contributions Welcome, No action Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Error Reporting Incorrect or improved errors from pandas Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

3 participants