Closed huaji1992 closed 4 years ago
iris = px.data.iris() import plotly_express as px tips = px.data.tips() gapminder = px.data.gapminder() election = px.data.election() wind = px.data.wind() carshare = px.data.carshare() px.scatter(tips, x="total_bill", y="tip", facet_row="time", facet_col="day", color="smoker", trendline="ols", category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]})
Hmm ok. can you tell me which versions of Python, pandas and numpy you're using?
I'm getting the error using version 1.16.4 of numpy and 3.7.3 of python In [78]: sys.version Out[78]: '3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 22:01:29) [MSC v.1900 64 bit (AMD64)]'
Any help?
@emmanuelle can you take a look at this one please? We see this warning sometimes depending on the version of statsmodels and numpy... it would be good to just figure out which recent versions of these dependencies avoid these issues...
pandas (>= 0.24.0) raises this warning. https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.ptp.html
I think using pandas (>= 0.24.0) and statsmodels (<= 0.9.0) causes this warning.
EDIT: I was able to reproduce this warning with pandas 0.24.0 and statsmodels 0.9.0.
EDIT: It turns out I was wrong. statsmodels version doesn't matter.
We can also reproduce the warning like this:
import numpy as np
import pandas as pd
s = pd.Series([0])
np.ptp(s)
This is because np.ptp(s)
calls s.ptp
.
https://github.com/numpy/numpy/blob/v1.17.0/numpy/core/fromnumeric.py#L2430-L2496
It seems this line causes the warning. https://github.com/statsmodels/statsmodels/blob/e2d768ae8da848dc46f63fae3059c5c4139007e0/statsmodels/tsa/tsatools.py#L103
One way to avoid the warning is convert a pandas series to a numpy array like below (I haven't tested yet but it should work):
- fit_results = sm.OLS(y, sm.add_constant(x)).fit()
+ fit_results = sm.OLS(y, sm.add_constant(x.values)).fit()
Ah, thanks for all the detective work @harupy ! Indeed just adding .values
there makes the warning go away :) I'll patch it tonight.
@nicolaskruchten You're welcome!
thanks so much @harupy yes this works much appreciated. thank you @nicolaskruchten for asking this question
This was bothering me to no end on a variable assignment. As someone new to Python, it was quite discouraging as I though I was doing something wrong. @harupy , thanks for your help - you just saved me from despair! hontou ni arigatou gozaimashita!
Can you provide any context on when this warning appears?