diff(axis=1) after insert results in unexpected NaN column · Issue #10907 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@dadkins

Description

@dadkins

The following code in pandas 0.16.2 demonstrates the problem:

import pandas as pd df = pd.DataFrame({'y': pd.Series([2]), 'z': pd.Series([3])}) df y z 0 2 3 df.insert(0, 'x', 1) df.diff(axis=1) x y z 0 NaN NaN 1

The following workaround produces the expected result:

df.T.diff().T x y z 0 NaN 1 1

Versions:

pd.show_versions()

INSTALLED VERSIONS

commit: None python: 2.7.10.final.0 python-bits: 64 OS: Linux OS-release: 2.6.18-400.1.1.el5 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: C

pandas: 0.16.2 nose: None Cython: None numpy: 1.9.2 sphinx: None patsy: 0.4.0 dateutil: 2.4.2 pytz: 2015.4 bottleneck: None tables: 3.1.1 numexpr: 2.3.1 matplotlib: 1.4.3 openpyxl: None xlrd: None xlwt: None xlsxwriter: None lxml: None bs4: None html5lib: None httplib2: None apiclient: None sqlalchemy: None pymysql: None psycopg2: None