Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index not iterable in Pandas 0.25.0 #28086

Closed
MatsZ opened this issue Aug 22, 2019 · 3 comments
Closed

Index not iterable in Pandas 0.25.0 #28086

MatsZ opened this issue Aug 22, 2019 · 3 comments

Comments

@MatsZ
Copy link

MatsZ commented Aug 22, 2019

Code Sample, a copy-pastable example if possible

import pandas as pd
import matplotlib.pyplot as plt

# Get graphs in the notebook:
%matplotlib inline

pd.show_versions()

df = pd.DataFrame({'A': [1, 2, 3, 4, 15, 20, 99]})

data = df['A']

plt.plot(data, (data.index.values + 1) / len(data))
plt.show()

plt.plot(data, (data.index + 1) / len(data))
plt.show()

Problem description

In Pandas 0.23.4 the percentiles in CDF graphs can be expressed as (data.index + 1) / len(data), but in Pandas 0.25.0 this has to be changed to (data.index.values + 1) / len(data). No distaster but lots of work to change in many scripts.

Expected Output

[two nice CDF plots]

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

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

pandas : 0.25.0
numpy : 1.16.2
pytz : 2019.2
dateutil : 2.8.0
pip : 19.2.2
setuptools : 41.0.1
Cython : 0.29.2
pytest : 4.0.2
hypothesis : None
sphinx : 1.8.2
blosc : None
feather : None
xlsxwriter : 1.1.2
lxml.etree : 4.2.5
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10
IPython : 7.2.0
pandas_datareader: None
bs4 : 4.6.3
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.2.5
matplotlib : 3.0.2
numexpr : 2.6.8
odfpy : None
openpyxl : 2.5.12
pandas_gbq : None
pyarrow : 0.11.1
pytables : None
s3fs : None
scipy : 1.1.0
sqlalchemy : 1.2.15
tables : 3.4.4
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.1.2


IndexError Traceback (most recent call last)
in
14 plt.show()
15
---> 16 plt.plot(data, (data.index + 1) / len(data))
17 plt.show()

/opt/anaconda/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py in plot(scalex, scaley, data, *args, **kwargs)
2811 return gca().plot(
2812 *args, scalex=scalex, scaley=scaley, **({"data": data} if data
-> 2813 is not None else {}), **kwargs)
2814
2815

/opt/anaconda/anaconda3/lib/python3.7/site-packages/matplotlib/init.py in inner(ax, data, *args, **kwargs)
1808 "the Matplotlib list!)" % (label_namer, func.name),
1809 RuntimeWarning, stacklevel=2)
-> 1810 return func(ax, *args, **kwargs)
1811
1812 inner.doc = _add_data_doc(inner.doc,

/opt/anaconda/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_axes.py in plot(self, scalex, scaley, *args, **kwargs)
1609 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D._alias_map)
1610
-> 1611 for line in self._get_lines(*args, **kwargs):
1612 self.add_line(line)
1613 lines.append(line)

/opt/anaconda/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in _grab_next_args(self, *args, **kwargs)
391 this += args[0],
392 args = args[1:]
--> 393 yield from self._plot_args(this, kwargs)
394
395

/opt/anaconda/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
376 func = self._makefill
377
--> 378 ncx, ncy = x.shape[1], y.shape[1]
379 if ncx > 1 and ncy > 1 and ncx != ncy:
380 cbook.warn_deprecated("2.2", "cycling among columns of inputs "

IndexError: tuple index out of range

@jorisvandenbossche
Copy link
Member

@MatsZ thanks for the report!

I assume this is the same as what was reported in matplotlib/matplotlib#14992 / #27775, which is fixed both on the pandas side as matplotlib side. So with the first bug fix release of either projects, this should be solved (pandas 0.25.1 is targetted to be released tomorrow).

@MatsZ
Copy link
Author

MatsZ commented Aug 22, 2019 via email

@TomAugspurger
Copy link
Contributor

No worries.

The 0.25.1 release should be today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants