You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IndexError: tuple index out of range with pandas 0.25. #14992
changed the title [-]IndexError: tuple index out of range after upgrade to 3.1.1[/-][+]IndexError: tuple index out of range with pandas 0.25.[/+]on Aug 6, 2019
@jorisvandenbossche wondering then if pandas should be throwing a warning or something since array[:,None] syntax is the numpy recommended way of expanding dims and so the expectation there is to return a 2D item.
@Foadsf in general, you will get much better responses from projects if you provide an easily understandable and testable examples (see http://www.sscce.org/ for a longer discussion as to why). The information we ask for in the issue template to guide you so we can help you as easily as possible.
@ImportanceOfBeingErnest yes, that is certainly inconsistent, and "kind of" a regression in pandas (which I also propose to fix in pandas itself for 0.25.1, see pandas-dev/pandas#27775 (comment))
I am saying "kind of" because we should decide what to do when you end up with a 2D Index (which is invalid, but currently you can get that with the indexing operation as idx[:, None]): return a 2D array or raise an error. series[:, None] does return a 2D numpy array, hence you get the correct shape.
But in any case, I think it would be good for matplotlib to not rely on this indexing aspect to convert a pandas Index into a 2D array-like.
Activity
jamespreed commentedon Aug 6, 2019
Looks like this commit changed how the indices were assigned by removing the
_xy_from_xymethod. This works as of 3.1.0, but not 3.1.1 (on Windows).Foadsf commentedon Aug 6, 2019
Downgrading to the previous versions doesn't help! There might be more issues IMHO ¯\_(ツ)_/¯
anntzer commentedon Aug 6, 2019
This is actually due to the upgrade to pandas 0.25:
This now prints
(3,) (3,), but with pandas 0.24 used to print(3,) (3, 1)which we relied on to convert input to 2D.Foadsf commentedon Aug 6, 2019
@anntzer downgrading to Pandas
0.24solved the problem!Foadsf commentedon Aug 6, 2019
I reported an issue on pandas repo here
[-]IndexError: tuple index out of range after upgrade to 3.1.1[/-][+]IndexError: tuple index out of range with pandas 0.25.[/+]jorisvandenbossche commentedon Aug 6, 2019
@story645 I am not fully sure we can provide an upstream fix (or at least not long term).
df.indexis a one-dimensional object, sodf.index[:, None]actually giving an Index that is 2D, could have been considered a bug in pandas.tacaswell commentedon Aug 6, 2019
@Foadsf Can you please paste a minimal copy-pastable example into this issue? SO links rot over time.
story645 commentedon Aug 6, 2019
@jorisvandenbossche wondering then if pandas should be throwing a warning or something since
array[:,None]syntax is the numpy recommended way of expanding dims and so the expectation there is to return a 2D item.jklymak commentedon Aug 7, 2019
What does np.newaxis give if we use that instead?
Foadsf commentedon Aug 7, 2019
Dear @tacaswell the Pandas guys were kind to edit my post here and add clear and concise examples demonstrating the issue.
jorisvandenbossche commentedon Aug 7, 2019
@Foadsf that's a reproducible example for just the pandas side, but I think @tacaswell is looking for an example that shows the error with matplotlib.
Something like
tacaswell commentedon Aug 7, 2019
Thanks @jorisvandenbossche
@Foadsf in general, you will get much better responses from projects if you provide an easily understandable and testable examples (see http://www.sscce.org/ for a longer discussion as to why). The information we ask for in the issue template to guide you so we can help you as easily as possible.
QuLogic commentedon Aug 7, 2019
@jklymak
np.newaxis is None; there is no difference between the two other than programmer clarity.ImportanceOfBeingErnest commentedon Aug 7, 2019
prints
This seems rather inconsistent.
Marking as release critical, because something needs to be done here.
FIX: support pandas 0.25
jorisvandenbossche commentedon Aug 8, 2019
@ImportanceOfBeingErnest yes, that is certainly inconsistent, and "kind of" a regression in pandas (which I also propose to fix in pandas itself for 0.25.1, see pandas-dev/pandas#27775 (comment))
I am saying "kind of" because we should decide what to do when you end up with a 2D Index (which is invalid, but currently you can get that with the indexing operation as
idx[:, None]): return a 2D array or raise an error.series[:, None]does return a 2D numpy array, hence you get the correct shape.But in any case, I think it would be good for matplotlib to not rely on this indexing aspect to convert a pandas Index into a 2D array-like.