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

Dividing Series of Decimal objects by Decimal raises AttributeError #9787

Closed
j-chmielewski opened this issue Apr 2, 2015 · 2 comments
Closed
Labels
Compat pandas objects compatability with Numpy or Python functions Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@j-chmielewski
Copy link

This worked fine with pandas 0.15:

In [24]: import pandas as pd
In [25]: from decimal import Decimal
In [26]: s = pd.Series([Decimal(10)] * 10)
In [27]: s / Decimal(5)
Out[27]: 
0    2
1    2
2    2
3    2
4    2
5    2
6    2
7    2
8    2
9    2
dtype: object

When I use 0.16.0, it raises:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-29-f6e1a63d5a28> in <module>()
----> 1 s / Decimal(5)

/home/jck/anaconda/lib/python2.7/site-packages/pandas/core/ops.pyc in wrapper(left, right, name)
    530             if hasattr(lvalues, 'values'):
    531                 lvalues = lvalues.values
--> 532             return left._constructor(wrap_results(na_op(lvalues, rvalues)),
    533                                      index=left.index, name=left.name,
    534                                      dtype=dtype)

/home/jck/anaconda/lib/python2.7/site-packages/pandas/core/ops.pyc in na_op(x, y)
    483             result, changed = com._maybe_upcast_putmask(result, ~mask, np.nan)
    484 
--> 485         result = com._fill_zeros(result, x, y, name, fill_zeros)
    486         return result
    487 

/home/jck/anaconda/lib/python2.7/site-packages/pandas/core/common.pyc in _fill_zeros(result, x, y, name, fill)
   1407         y = np.array(y)
   1408 
-> 1409     if is_integer_dtype(y):
   1410 
   1411         if (y == 0).any():

/home/jck/anaconda/lib/python2.7/site-packages/pandas/core/common.pyc in is_integer_dtype(arr_or_dtype)
   2448 
   2449 def is_integer_dtype(arr_or_dtype):
-> 2450     tipo = _get_dtype_type(arr_or_dtype)
   2451     return (issubclass(tipo, np.integer) and
   2452             not issubclass(tipo, (np.datetime64, np.timedelta64)))

/home/jck/anaconda/lib/python2.7/site-packages/pandas/core/common.pyc in _get_dtype_type(arr_or_dtype)
   2439     elif isinstance(arr_or_dtype, CategoricalDtype):
   2440         return CategoricalDtypeType
-> 2441     return arr_or_dtype.dtype.type
   2442 
   2443 

AttributeError: 'Decimal' object has no attribute 'dtype'
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.9.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-24-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.16.0
nose: 1.3.4
Cython: 0.21
numpy: 1.9.2
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 2.2.0
sphinx: 1.2.3
patsy: 0.3.0
dateutil: 2.4.2
pytz: 2015.2
bottleneck: None
tables: 3.1.1
numexpr: 2.3.1
matplotlib: 1.4.0
openpyxl: 1.8.5
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: 0.5.7
lxml: 3.4.0
bs4: 4.3.2
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 0.9.7
pymysql: None
psycopg2: None
@jreback jreback added Bug Compat pandas objects compatability with Numpy or Python functions labels Apr 2, 2015
@jreback jreback added this to the Next Major Release milestone Apr 2, 2015
@jreback
Copy link
Contributor

jreback commented Apr 2, 2015

I am not a big fan of Decimal, but I suppose should regain compat for this. pull-requests welcome.

@jreback jreback added Regression Functionality that used to work in a prior pandas version and removed Bug labels Apr 2, 2015
hsperr added a commit to hsperr/pandas that referenced this issue Apr 13, 2015
… support

type or dtype. pandas-dev#9787
ENH: replace np.isscalar with better lib.isscalar
ADD: Test decimal division
@jreback jreback modified the milestones: 0.16.1, Next Major Release Apr 13, 2015
hsperr added a commit to hsperr/pandas that referenced this issue Apr 13, 2015
… support

type or dtype. pandas-dev#9787
ENH: replace np.isscalar with better lib.isscalar
ADD: Test decimal division
hsperr added a commit to hsperr/pandas that referenced this issue Apr 13, 2015
… support

type or dtype. pandas-dev#9787
ENH: replace np.isscalar with better lib.isscalar
ADD: Test decimal division
hsperr added a commit to hsperr/pandas that referenced this issue Apr 13, 2015
… support

type or dtype. pandas-dev#9787
ENH: replace np.isscalar with better lib.isscalar
ADD: Test decimal division
@jreback
Copy link
Contributor

jreback commented Apr 14, 2015

closed by #9871

@jreback jreback closed this as completed Apr 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants