Python 导致值错误的子批次回归

Python 导致值错误的子批次回归,python,python-3.x,pandas,dataframe,matplotlib,Python,Python 3.x,Pandas,Dataframe,Matplotlib,我有一个包含房屋地址的数据框,以及一个api调用,其中列出了房屋半径5英里内最近的高中的校名和排名(共5颗星)。如果没有高中,那就在那一行加上一个南 我试着做了两个散点图的子图,比较附近有高中和附近没有高中的房子的大小和价格 这就是我过去努力实现的目标: x_axis = data_df.loc[data_df['High School'].isna(), ["Total Sq Ft"]] y_axis = data_df.loc[data_df['High School']

我有一个包含房屋地址的数据框,以及一个api调用,其中列出了房屋半径5英里内最近的高中的校名排名(共5颗星)。如果没有高中,那就在那一行加上一个南

我试着做了两个散点图的子图,比较附近有高中和附近没有高中的房子的大小和价格

这就是我过去努力实现的目标:

x_axis = data_df.loc[data_df['High School'].isna(), ["Total Sq Ft"]]
y_axis = data_df.loc[data_df['High School'].isna(), ["Sale Price"]]
x_axis_2 = data_df.loc[data_df['High School'].notna(), ["Total Sq Ft"]]
y_axis_2 = data_df.loc[data_df['High School'].notna(), ["Sale Price"]]

fig = plt.figure()
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212)
(ax1slope, ax1intercept, ax1rvalue, ax1pvalue, ax1stderr) = st.linregress(x_axis, y_axis)
ax1_regress_values = x_axis * ax1slope + ax1intercept
ax1_line_eq = "y = " + str(round(ax1slope,2)) + "x + " + str(round(ax1intercept,2))
ax1.annotate(ax1_line_eq,(0,2000000),fontsize=10,color="blue")
ax1.plot(x_axis, ax1_regress_values,"b--")
ax1.scatter(x_axis, y_axis, s=10, c='b', marker="s", label='No HS nearby')

(ax2slope, ax2intercept, ax2rvalue, ax2pvalue, ax2stderr) = st.linregress(x_axis_2, y_axis_2)
ax2_regress_values = x_axis_2 * ax2slope + ax2intercept
ax2_line_eq = "y = " + str(round(ax2slope,2)) + "x + " + str(round(ax2intercept,2))
ax2.annotate(ax2_line_eq,(4000,3000000),fontsize=10,color="red")
ax2.plot(x_axis_2, ax2_regress_values,"r--")
ax2.scatter(x_axis_2, y_axis_2, s=10, c='r', marker="o", label='HS nearby')
ax1.legend(loc='best')
ax2.legend(loc='best')
plt.show()
这就是出现的错误:

ValueError                                Traceback (most recent call last)
<ipython-input-28-4f54bd25003b> in <module>
      9 ax1 = fig.add_subplot(211)
     10 ax2 = fig.add_subplot(212)
---> 11 (ax1slope, ax1intercept, ax1rvalue, ax1pvalue, ax1stderr) = st.linregress(x_axis, y_axis)
     12 ax1_regress_values = x_axis * ax1slope + ax1intercept
     13 ax1_line_eq = "y = " + str(round(ax1slope,2)) + "x + " + str(round(ax1intercept,2))

~\anaconda3\lib\site-packages\scipy\stats\_stats_mstats_common.py in linregress(x, y)
    114 
    115     # average sum of squares:
--> 116     ssxm, ssxym, ssyxm, ssym = np.cov(x, y, bias=1).flat
    117     r_num = ssxym
    118     r_den = np.sqrt(ssxm * ssym)

ValueError: too many values to unpack (expected 4)
ValueError回溯(最近一次调用)
在里面
9 ax1=图添加_子批次(211)
10 ax2=图添加子批次(212)
--->11(ax1slope,ax1intercept,ax1rvalue,ax1pvalue,ax1stderr)=圣林回归(x_轴,y_轴)
12 ax1_回归_值=x_轴*ax1坡度+ax1相交
13 ax1_line_eq=“y=”+str(圆形(ax1slope,2))+“x+”+str(圆形(ax1intercept,2))
linregresse(x,y)中的~\anaconda3\lib\site packages\scipy\stats\\u stats\u mstats\u common.py
114
115#平均平方和:
-->116 ssxm,ssxym,ssyxm,ssym=np.cov(x,y,偏压=1)。平坦
117 r_num=ssxym
118 r_den=np.sqrt(ssxm*ssym)
ValueError:要解压缩的值太多(应为4个)
我在jupyter笔记本中使用了%matplotlib笔记本,在添加用于回归2个散点图的代码之前,子绘图脚本运行良好。有没有办法让Linretrace表现出来