Skip to content

quantile() does not work with columns of type Decimal #13157

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

Closed
mavroprovato opened this issue May 12, 2016 · 4 comments
Closed

quantile() does not work with columns of type Decimal #13157

mavroprovato opened this issue May 12, 2016 · 4 comments
Labels
Dtype Conversions Unexpected or buggy dtype conversions Enhancement Usage Question

Comments

@mavroprovato
Copy link

Code Sample, a copy-pastable example if possible

This snippet does not work (returns an empty DataFrame)

pd.DataFrame([
    Decimal(162.7646939720129171), Decimal(162.5470404198062433),
    Decimal(162.9334883683360258), Decimal(161.7975872981700753),
    Decimal(160.9450499461786868), Decimal(163.1648865446716900),
]).quantile(0.8)

Expected Output

This snippet works as expected (returns a Series with one value)

pd.DataFrame([
    162.7646939720129171, 162.5470404198062433,
    162.9334883683360258, 161.7975872981700753,
    160.9450499461786868, 163.1648865446716900,
]).quantile(0.8)

Shouldn't both snippets work the same way?

output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.4.3.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-86-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.1
nose: None
pip: 8.1.2
setuptools: 20.9.0
Cython: None
numpy: 1.11.0
scipy: None
statsmodels: None
xarray: None
IPython: 4.2.0
sphinx: None
patsy: None
dateutil: 2.5.2
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: 0.7.2.None
psycopg2: 2.6.1 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: None
pandas_datareader: None

@TomAugspurger
Copy link
Contributor

I don't think this is supported. numpy.percentile doesn't even work on Decimals, so not much we can do.

@jreback
Copy link
Contributor

jreback commented May 12, 2016

its possible (esp in the new way .quantile works), but we don't support Decimal very much.

@jreback
Copy link
Contributor

jreback commented May 12, 2016

what we really need is Block support for Decimal. Though I don't see much actual utility for this.

closing as no action, but if you'd like to submit a PR would be ok with it.

@jreback jreback closed this as completed May 12, 2016
@jreback jreback added this to the No action milestone May 12, 2016
@jreback jreback added Enhancement Dtype Conversions Unexpected or buggy dtype conversions labels May 12, 2016
@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented May 12, 2016

Some things do work, eg mean, also in numpy:

In [57]: a = np.array([Decimal(160.9450499461786868), Decimal(163.1648865446716900)])

In [58]: a
Out[58]:
array([Decimal('160.94504994617869897410855628550052642822265625'),
       Decimal('163.164886544671702495179488323628902435302734375')], dtype=object)

In [59]: a.mean()
Out[59]: Decimal('162.0549682454252007346440223')

So I would rather raise this issue on the numpy side, rather than starting to implement a specific Block for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Enhancement Usage Question
Projects
None yet
Development

No branches or pull requests

4 participants