question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 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:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
gfyoungcommented, Feb 7, 2019

@Vibhu-Agarwal : By all means! Investigation and PR are welcome!

0reactions
gfyoungcommented, Feb 2, 2020

@gfyoung just to be clear, you mean opening a PR that includes an additional test with the verbatim(ish) code sample?

Correct

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error while trying to interpolate across rows in pandas dataframe
df.interpolate(axis=1) *** TypeError: Cannot interpolate with all NaNs. How to fix this and get interpolation across rows?
Read more >
pandas.DataFrame.interpolate — pandas 1.5.2 documentation
Keyword arguments to pass on to the interpolating function. Returns the same object type as the caller, interpolated at some or all NaN...
Read more >
apache_beam.dataframe.frames - Apache Beam
Only ``axis=columns`` is allowed.""" if axis in (0, 'index'): # axis=rows imposes an ordering on the DataFrame which we do not support raise...
Read more >
pandas powerful python - Química - 49 - Passei Direto
Veja grátis o arquivo pandas powerful python enviado para a disciplina de Química ... or interpolate: In [237]: ts2.reindex(ts.index).fillna(method="ffill") ...
Read more >
lux.core.frame.LuxDataFrame — Lux 0.1.2 documentation
quantile ([q, axis, numeric_only, interpolation]), Return values at the given quantile over ... Modify in place using non-NA values from another DataFrame.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found