Skip to content

Dataframe diff unexpected result #11996

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

Dataframe diff unexpected result #11996

kdebrab opened this issue Jan 8, 2016 · 2 comments
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations

Comments

@kdebrab
Copy link
Contributor

kdebrab commented Jan 8, 2016

Pandas version 0.17.1:

In [1]: import pandas as pd
   ...: data = pd.DataFrame({'d':[1,2,3],'e':[1.5,2,3],'f':[2,2,3]},index=list('abc'))
   ...: data.diff(axis=1)
Out[1]: 
    d   e  f
a NaN NaN  1
b NaN NaN  0
c NaN NaN  0

Hint: the following gives expected result

In [2]: data.astype(float).diff(axis=1)
Out[2]: 
    d    e    f
a NaN  0.5  0.5
b NaN  0.0  0.0
c NaN  0.0  0.0
@TomAugspurger
Copy link
Contributor

This seems similar to #10930

This comment suggests that the fix there won't work for mixed dtypes (but you only have ints)

@TomAugspurger TomAugspurger added Bug Numeric Operations Arithmetic, Comparison, and Logical operations 2/3 Compat and removed 2/3 Compat labels Jan 8, 2016
@jreback
Copy link
Contributor

jreback commented Jan 8, 2016

this is a dupe of #10539

@jreback jreback closed this as completed Jan 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

No branches or pull requests

3 participants