A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/10907 below:

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

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4