Skip to content

Commit d33d654

Browse files
committed
FIX: support pandas 0.25
closes matplotlib#14992
1 parent e86c9cd commit d33d654

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/matplotlib/cbook/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,11 @@ def _check_1d(x):
13261326
return np.atleast_1d(x)
13271327
else:
13281328
try:
1329-
x[:, None]
1329+
shape = x[:, None].shape
1330+
# work around https://github.com/pandas-dev/pandas/issues/27775
1331+
# which mean the shape is not as expected
1332+
if len(shape) != 2:
1333+
return np.atleast_1d(x)
13301334
return x
13311335
except (IndexError, TypeError):
13321336
return np.atleast_1d(x)

lib/matplotlib/tests/test_axes.py

+6
Original file line numberDiff line numberDiff line change
@@ -5552,6 +5552,12 @@ def test_pandas_errorbar_indexing(pd):
55525552
ax.errorbar('x', 'y', xerr='xe', yerr='ye', data=df)
55535553

55545554

5555+
def test_pandas_index_shape(pd):
5556+
df = pd.DataFrame({"XX" : [4,5,6], "YY" : [7,1,2]})
5557+
fig, ax = plt.subplots()
5558+
ax.plot(df.index, df['YY'])
5559+
5560+
55555561
def test_pandas_indexing_hist(pd):
55565562
ser_1 = pd.Series(data=[1, 2, 2, 3, 3, 4, 4, 4, 4, 5])
55575563
ser_2 = ser_1.iloc[1:]

0 commit comments

Comments
 (0)