DataFrame.interpolate(axis='columns') throws exception while DataFrame.interpolate(axis=1) not
See original GitHub issueCode 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
https://github.com/pandas-dev/pandas/blob/c460a929e19535335085c652e7e35eee1d9c7c2e/pandas/core/generic.py#L6800
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
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (10 by maintainers)
@Vibhu-Agarwal : By all means! Investigation and PR are welcome!
Correct