Skip to content

Pandas sum column with scalar results in zeros #12167

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
jpiabrantes opened this issue Jan 28, 2016 · 2 comments
Closed

Pandas sum column with scalar results in zeros #12167

jpiabrantes opened this issue Jan 28, 2016 · 2 comments
Labels
Numeric Operations Arithmetic, Comparison, and Logical operations Usage Question

Comments

@jpiabrantes
Copy link

I am summing a column of a pandas dataframe with a scalar and the result is a column full of zeros. The weird thing is that sometimes it will return zeros and sometimes it won't.

With this code I get a similar error:

import pandas as pd
import numpy as np
from pdb import set_trace as pdb

for _ in xrange(100):
    data = np.random.randint(1,100000,1000000)
    df = pd.DataFrame(data,columns=['column'])
    scalar = np.random.randint(1,100000)
    df.column += scalar
    if df.column.max()==0:
        pdb()

My df.column gets full of zeros every now and then.

Discussion on stackoverflow:
http://stackoverflow.com/questions/35057969/pandas-sum-column-with-scalar-results-in-zeros

@jreback
Copy link
Contributor

jreback commented Jan 28, 2016

post pd.show_versions()

this is almost certainly #12023

you are on windows with numexpr=2.4.4

upgrade to numexpr=2.4.6 and all will be well

@jreback jreback added Usage Question Numeric Operations Arithmetic, Comparison, and Logical operations labels Jan 28, 2016
@jpiabrantes
Copy link
Author

Here are my versions

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en_GB

pandas: 0.17.1
nose: 1.3.7
pip: 8.0.1
setuptools: None
Cython: 0.23.4
numpy: 1.10.1
scipy: 0.16.0
statsmodels: 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.4.4
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: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.9
pymysql: None
psycopg2: None
Jinja2: None

I updated to numexpr=2.4.6 and problem got fixed! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Numeric Operations Arithmetic, Comparison, and Logical operations Usage Question
Projects
None yet
Development

No branches or pull requests

2 participants