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

Behaviour of .sum() inconsistent between Series and DataFrame when summing Decimals #13446

Closed
tui-rob opened this issue Jun 15, 2016 · 2 comments
Labels
API Design Dtype Conversions Unexpected or buggy dtype conversions Usage Question

Comments

@tui-rob
Copy link
Contributor

tui-rob commented Jun 15, 2016

Using sum() on a Series of Decimal datatypes returns a Decimal. However, using sum() on a DataFrame of Decimal datatypes returns floats.

I think it would be more consistent for the DataFrame sum() to return Decimals.

Code Sample

import pandas as pd
from decimal import Decimal

df = pd.DataFrame({'a':[Decimal('1.0'), Decimal('2.0')],
                   'b':[Decimal('3.0'), Decimal('4.0')]})

type(df['a'].sum()), type(df.sum()[0])

Out[1]: (decimal.Decimal, numpy.float64)

Expected Output

Out[1]: (decimal.Decimal, decimal.Decimal)

output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: x86
processor: x86 Family 6 Model 42 Stepping 7, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.0
nose: 1.3.7
pip: 7.1.2
setuptools: 18.5
Cython: 0.23.4
numpy: 1.10.1
scipy: 0.16.0
statsmodels: 0.6.1
xarray: None
IPython: 4.0.1
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5
matplotlib: 1.5.0
openpyxl: 2.2.6
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.7.7
lxml: 3.4.4
bs4: 4.4.1
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: 1.0.9
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.38.0
@jreback
Copy link
Contributor

jreback commented Jun 15, 2016

Decimal is not a first class type, nor will it likely be going forward. So this is unsupported.

xref #13157 (and other issues if you want to look)

@jreback jreback closed this as completed Jun 15, 2016
@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Usage Question API Design labels Jun 15, 2016
@tui-rob
Copy link
Contributor Author

tui-rob commented Jun 16, 2016

Understood and thanks for the quick response and helpful xrefs

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

No branches or pull requests

3 participants