Skip to content

DataFrame.interpolate(axis='columns') throws exception while DataFrame.interpolate(axis=1) not #25190

Closed
@heavelock

Description

@heavelock

Code Sample, a copy-pastable example if possible

import numpy as np
import pandas as pd

x = np.linspace(0,100,1000)
y = np.sin(x)
df = pd.DataFrame(data=np.tile(y, (10,1)), index=np.arange(10), columns=x)
df.reindex(columns=x*1.005).interpolate(method='linear', axis=1)

df.reindex(columns=x*1.005).interpolate(method='linear', axis='columns')

Problem description

The interpolation with argument axis set to 'columns' throws an exception from

ax = _maybe_transposed_self._get_axis_number(ax)

The exception is:

UnboundLocalError: local variable 'ax' referenced before assignment

The same method for parameter `axis=1' works fine.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.7.0.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-44-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.24.1
pytest: None
pip: 18.1
setuptools: 40.6.3
Cython: None
numpy: 1.15.4
scipy: 1.1.0
pyarrow: None
xarray: 0.11.2
IPython: 7.2.0
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: 4.2.5
bs4: None
html5lib: None
sqlalchemy: 1.2.15
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselvesNeeds TestsUnit test(s) needed to prevent regressionsgood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions