Getting the regression line to plot from a Pandas regression

后端 未结 1 847
Happy的楠姐
Happy的楠姐 2020-12-19 16:43

I have tried with both the (pandas)pd.ols and the (statsmodels)sm.ols to get a regression scatter plot with the regression line, I can get the scatter plot but I ca

相关标签:
1条回答
  • 2020-12-19 17:08

    Check what values you have in your arrays and variables.

    My guess is that your x is just nans, because you use Python's min and max. At least that happens with the version of Pandas that I have currently open.

    The min and max methods should work, since they know how to handle nans or missing values

    >>> x = pd.Series([np.nan,2], index=['const','slope'])
    >>> x
    const   NaN
    slope     2
    dtype: float64
    
    >>> min(x)
    nan
    >>> max(x)
    nan
    
    >>> x.min()
    2.0
    >>> x.max()
    2.0
    
    0 讨论(0)
提交回复
热议问题