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
values.
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]]Expected Output
>>> s = pd.Series([-1.])
>>> pd.cut(s, 1)
0 (-1.001, -0.999]
dtype: category
Categories (1, object): [(-1.001, -0.999]]
Output of pd.show_versions()
INSTALLED VERSIONS ------------------ commit: None python: 3.4.3.final.0 python-bits: 64 OS: Linux OS-release: 4.4.0-45-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8
pandas: 0.18.1
nose: 1.3.1
pip: 1.5.4
setuptools: 28.0.0
Cython: 0.20.1post0
numpy: 1.11.1
scipy: 0.18.0
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.4.8
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999
httplib2: 0.8
apiclient: None
sqlalchemy: 1.0.14
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: 0.2.1
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4