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

DataFrame.cumsum() breaks when using a DataFrame that was filled using the isnan() function #5103

Closed
jdavidheiser opened this issue Oct 4, 2013 · 4 comments

Comments

@jdavidheiser
Copy link

Most help documents I've seen suggest using the fillna() function to fill a DataFrame. However, if you try to use the results of that fill operation with other functions, it can break. For example, the following code:

df = DataFrame(index=["A","B","C"], columns = [1,2,3,4,5]) df2 = df.fillna(1) df2.cumsum()

Fails with the following error message:

 File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/pandas/core/generic.py", line 827, in cumsum
    mask = np.isnan(self.values)
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

However, creating a DataFrame filled with ones using the following works just fine:

df = DataFrame(np.ones((3,5)),index=["A","B","C"], columns = [1,2,3,4,5])

@jtratner
Copy link
Contributor

jtratner commented Oct 4, 2013

What version are you using? (pandas.__version__) Works on current master.

@jreback
Copy link
Contributor

jreback commented Oct 4, 2013

this was a bug in 0.12...fixed in master (but there is another bug unrelated)......

@jdavidheiser
Copy link
Author

I am using 0.12.0, mac OS X, Python 2.7.3

I'll admit I haven't tried it with the development version - if it's fixed there, awesome! In the meantime, using numpy to populate the data works.

On Oct 3, 2013, at 5:21 PM, Jeff Tratner notifications@github.com wrote:

What version are you using? (pandas.version) Works on current master.


Reply to this email directly or view it on GitHub.

@jtratner
Copy link
Contributor

jtratner commented Oct 4, 2013

regardless thanks for pointing this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants