Skip to content

Commit e8fa673

Browse files
authored
FIX: support pandas 0.25 (#15007)
FIX: support pandas 0.25
2 parents 3c60590 + df4b7dc commit e8fa673

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,13 @@ def _check_1d(x):
13261326
return np.atleast_1d(x)
13271327
else:
13281328
try:
1329-
x[:, None]
1329+
ndim = x[:, None].ndim
1330+
# work around https://github.com/pandas-dev/pandas/issues/27775
1331+
# which mean the shape is not as expected. That this ever worked
1332+
# was an unintentional quirk of pandas the above line will raise
1333+
# an exception in the future.
1334+
if ndim < 2:
1335+
return np.atleast_1d(x)
13301336
return x
13311337
except (IndexError, TypeError):
13321338
return np.atleast_1d(x)

lib/matplotlib/tests/test_axes.py

Lines changed: 6 additions & 0 deletions
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)