8000 Improve Pandas conversion · matplotlib/matplotlib@a0488df · GitHub
[go: up one dir, main page]

Skip to content

Commit a0488df

Browse files
author
Oscar Gustafsson
committed
Improve Pandas conversion
1 parent 2e95730 commit a0488df

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7907,8 +7907,8 @@ def violinplot(self, dataset, positions=None, vert=True, widths=0.5,
79077907
"""
79087908

79097909
def _kde_method(X, coords):
7910-
if hasattr(X, 'values'): # support pandas.Series
7911-
X = X.values
7910+
if hasattr(X, 'to_numpy'): # support pandas.Series
7911+
X = X.to_numpy()
79127912
# fallback gracefully if the vector contains only one value
79137913
if np.all(X[0] == X):
79147914
return (X[0] == coords).astype(float)

lib/matplotlib/dates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,9 @@ def date2num(d):
437437
The Gregorian calendar is assumed; this is not universal practice.
438438
For details see the module docstring.
439439
"""
440-
if hasattr(d, "values"):
440+
if hasattr(d, "to_numpy"):
441441
# this unpacks pandas series or dataframes...
442-
d = d.values
442+
d = d.to_numpy()
443443

444444
# make an iterable, but save state to unpack later:
445445
iterable = np.iterable(d)

lib/matplotlib/units.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ class Registry(dict):
180180

181181
def get_converter(self, x):
182182
"""Get the converter interface instance for *x*, or None."""
183-
if hasattr(x, "values"):
184-
x = x.values # Unpack pandas Series and DataFrames.
183+
if hasattr(x, "to_numpy"):
184+
x = x.to_numpy() # Unpack pandas Series and DataFrames.
185185
if isinstance(x, np.ndarray):
186186
# In case x in a masked array, access the underlying data (only its
187187
# type matters). If x is a regular ndarray, getdata() just returns

0 commit comments

Comments
 (0)
0