77import io
88import re
99import sys
10+ import warnings
1011
1112from _plotly_utils .optional_imports import get_module
1213
@@ -100,7 +101,11 @@ def copy_to_readonly_numpy_array(v, kind=None, force_numeric=False):
100101 elif v .dtype .kind == "M" :
101102 # Convert datetime Series/Index to numpy array of datetimes
102103 if isinstance (v , pd .Series ):
103- v = v .dt .to_pydatetime ()
104+ with warnings .catch_warnings ():
105+ warnings .simplefilter ("ignore" , FutureWarning )
106+ # Series.dt.to_pydatetime will return Index[object]
107+ # https://github.com/pandas-dev/pandas/pull/52459
108+ v = np .array (v .dt .to_pydatetime ())
104109 else :
105110 # DatetimeIndex
106111 v = v .to_pydatetime ()
@@ -109,7 +114,13 @@ def copy_to_readonly_numpy_array(v, kind=None, force_numeric=False):
109114 if dtype .kind in numeric_kinds :
110115 v = v .values
111116 elif dtype .kind == "M" :
112- v = [row .dt .to_pydatetime ().tolist () for i , row in v .iterrows ()]
117+ with warnings .catch_warnings ():
118+ warnings .simplefilter ("ignore" , FutureWarning )
119+ # Series.dt.to_pydatetime will return Index[object]
120+ # https://github.com/pandas-dev/pandas/pull/52459
121+ v = [
122+ np .array (row .dt .to_pydatetime ()).tolist () for i , row in v .iterrows ()
123+ ]
113124
114125 if not isinstance (v , np .ndarray ):
115126 # v has its own logic on how to convert itself into a numpy array
0 commit comments