Hello,
After updating Plotly, I started receiving the following FutureWarning:
python3.11/site-packages/_plotly_utils/basevalidators.py:105: FutureWarning:
The behavior of DatetimeProperties.to_pydatetime is deprecated, in a future version this will return a Series containing python datetime objects instead of an ndarray. To retain the old behavior, call `np.array` on the result
I’m not explicitly using to_pydatetime() in my code. However, I am using a Pandas DataFrame to build various Plotly graphs over time, where the x-axis is populated with Pandas datetime objects (from a DataFrame column).
Does anyone have any suggestions on how to address this warning? (I don’t think explicitly converting the datetime properties to a NumPy array is the solution in this case.)
Having the same issue. I have created a venv for my project and am facing the same Future error, and I have made the suggested changes to the basevalidator.py file by calling np.array() function on the said lines, even though the error persists.
This is due to a change in the Pandas API for the behaviour of pandas.Series.dt.to_pydatetime, which Plotly (not Dash) uses internally. Unfortunately as an end user the only thing we can do is suppress the FutureWarning. It’s something that will have to be addressed in the Plotly package.
Here’s how you can suppress this warning, but it will be global so be aware that it will suppress all FutureWarning messages .
Edit: forgot to include the code snippet:
import warnings
warnings.simplefilter("ignore", category=FutureWarning)
# your plotly code
Or alternatively as a context manager so the ignoring is localised to only what occurs in the with block (to reduce the chances of you suppressing a different FutureWarning that you might have wanted to know about):
with warnings.catch_warnings():
warnings.simplefilter("ignore", FutureWarning)
# your plotly code