import pandas as pd
import numpy as np
from jqdata import gta
import matplotlib.pyplot as plt
import datetime
import statsmodels.api as sm
(包括钢材表观消费量、M2、房屋新开工面积、房屋竣工面积、固定资产投资完成额、商品房销售面积、基础设施建设投资、房地产开发投资完成额、钢铁产量等的月度数据)
steel_fd_data = pd.read_excel('钢铁基本面数据.xls',index_col=0)
###由于数据是wind直接下来的,所以不太干净,先预处理一下、去掉一些注释行
steel_fd_data = steel_fd_data[1:-2]
##数据钢材表观消费量为主,截断此数据开始之前的日期,此数据从2004年1月开始
steel_fd_data = steel_fd_data[steel_fd_data.index>=datetime.datetime(2004,1,1)]
因为有些数据是当年累计值(比如房屋新开工面积),为了方便之后做TTM环比比较,先将其处理为当月数据
由于一月份大多属于过年春节期间,因此不少数据在一月份为缺失值
need_adjust_columns = ['房屋新开工面积:累计值','房屋竣工面积:累计值','商品房销售面积:累计值','固定资产投资完成额:累计值',
'固定资产投资完成额:基础设施建设投资:累计值','房地产开发投资完成额:累计值']
steel_fd_data['month'] = steel_fd_data.index.map(lambda x:x.month)
#这些列都是一月份缺失数据的
for column in need_adjust_columns:
if column != '固定资产投资完成额:基础设施建设投资:累计值':
steel_fd_data[column.split(':')[0]] = steel_fd_data[column] - steel_fd_data[column].shift(1)
steel_fd_data.ix[steel_fd_data['month']<=2,column.split(':')[0]] = steel_fd_data[steel_fd_data['month']<=2][column]
else:
steel_fd_data[column.split(':')[1]] = steel_fd_data[column] - steel_fd_data[column].shift(1)
steel_fd_data.ix[steel_fd_data['month']<=2,column.split(':')[0]] = steel_fd_data[steel_fd_data['month']<=2][column]
###钢铁行业收入一月份没有缺失
column_ = '钢铁行业:大中型企业:销售收入:累计值'
steel_fd_data['钢铁行业销售收入'] = steel_fd_data[column_] - steel_fd_data[column_].shift(1)
steel_fd_data.ix[steel_fd_data['month'] == 1,'钢铁行业销售收入'] = steel_fd_data[steel_fd_data['month']==1][column_]
#取出接下来需要用的主要数据
data_columns_list = steel_fd_data.columns.tolist()
clean_data = steel_fd_data[data_columns_list[:2]+data_columns_list[-7:]+['产量:汽车:当月值']]
#去除第一行
clean_data = clean_data[1:]
clean_data.fillna(0,inplace=True)
TTM_columns = ['表观消费量:钢材:当月值','房屋新开工面积','房屋竣工面积','固定资产投资完成额','基础设施建设投资',\
'商品房销售面积','房地产开发投资完成额','钢铁行业销售收入','产量:汽车:当月值']
for column in TTM_columns:
clean_data[column+'TTM'] = pd.rolling_sum(clean_data[column],12)
clean_data[column+'TTM_环比'] = clean_data[column+'TTM']/clean_data[column+'TTM'].shift(1)-1
这里要对钢材表观消费量数据做一下调整:原因是其数据的不规整性:
其数据在15年及之前在1、2月份都是有的,但是16年之后1、2月份都缺失,如果这时候直接TTM环比的话,16年年初的时候将会有一个大幅的下降, 但这其实是由数据的不规整带来的。因此,在这里将16、17年1、2月的TTM环比数据都改为0
同样,汽车产量从14年之后1、2月的TTM环比数据都改为0
截取整段数据从2006年开始
clean_data['year'] = clean_data.index.map(lambda x:x.year)
clean_data['month'] = clean_data.index.map(lambda x:x.month)
clean_data.ix[(clean_data['year'].isin([2016,2017]))&(clean_data['month'].isin([1,2])),'表观消费量:钢材:当月值TTM_环比'] = 0
clean_data.ix[(clean_data['year'].isin([2014,2015,2016,2017]))&(clean_data['month'].isin([1,2])),'产量:汽车:当月值TTM_环比'] = 0
clean_data = clean_data[clean_data['year']>=2006]
clean_data.ix[(clean_data['year'] == 2006)&(clean_data['month']==8),'商品房销售面积TTM_环比'] = 0
/opt/conda/lib/python3.4/site-packages/pandas/core/indexing.py:415: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self.obj[item] = s
use_columns = [i+'TTM_环比' for i in TTM_columns]+['M2:同比']
use_data = clean_data[use_columns]
use_data.dropna(inplace=True)
###由于列名太长,这里做一个简写,但其值是表示的为TTM_环比值(但M2为同比值)
use_data.columns = ['钢材消费量TTM环比','新开工房TTM环比','竣工房TTM环比','固投TTM环比',\
'基建TTM环比','房销售面积TTM环比','房地产投资TTM环比','钢铁行业收入TTM环比','汽车产量TTM环比','M2']
/opt/conda/lib/python3.4/site-packages/ipykernel/__main__.py:3: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy app.launch_new_instance()
def plot_line_chart(x_axis,y1_axis,y2_axis,label1,label2):
Fig = plt.figure(figsize(10,8))
Ax = Fig.add_subplot(111)
lines = Ax.plot(x_axis,y1_axis,'r-',x_axis,y2_axis,'b-')
lines[0].set_label(label1)
lines[1].set_label(label2)
Ax.legend(loc = 0)
def plot_line_chart_double_yaxis(x_axis,y1_axis,y2_axis,label1,label2):
Fig = plt.figure(figsize(10,8))
Ax = Fig.add_subplot(111)
Ax.plot(x_axis,y1_axis,'r-')
Ax.set_ylabel(label1)
Ax_ = Ax.twinx()
Ax_.plot(x_axis,y2_axis,'b-')
Ax_.set_ylabel(label2)
def calculate_lag(data,column1,column2):
regre_results=[]
for i in range(-5,6):
reg_data = pd.concat([data[column1].shift(i),data[column2]],axis =1)
reg_data.dropna(inplace=True)
y=reg_data[column1]
x=reg_data[column2]
x=sm.add_constant(x)
est=sm.OLS(y,x)
results=est.fit()
r2 = results.rsquared
coef = results.params[1]
p = results.pvalues[1]
corr = reg_data[column1].corr(reg_data[column2])
regre_results.append([i,corr,coef,p,r2])
regre_df = pd.DataFrame(regre_results,columns=['领先期','相关系数','回归系数','P值','R方'])
return regre_df
plot_line_chart(use_data.index,use_data['钢材消费量TTM环比'],use_data['新开工房TTM环比'],'钢材表观消费量:TTM环比','房屋新开工面积:TTM环比')
chart_xkg_gxf = calculate_lag(use_data,'新开工房TTM环比','钢材消费量TTM环比')
chart_xkg_gxf
领先期 | 相关系数 | 回归系数 | P值 | R方 | |
---|---|---|---|---|---|
0 | -5 | 0.494652 | 1.210657 | 8.057526e-10 | 0.244680 |
1 | -4 | 0.511898 | 1.250358 | 1.389922e-10 | 0.262039 |
2 | -3 | 0.493004 | 1.204668 | 7.025351e-10 | 0.243053 |
3 | -2 | 0.500122 | 1.220213 | 3.145176e-10 | 0.250122 |
4 | -1 | 0.514065 | 1.256256 | 7.041873e-11 | 0.264262 |
5 | 0 | 0.470194 | 1.142141 | 3.548642e-09 | 0.221082 |
6 | 1 | 0.393328 | 0.957595 | 1.401036e-06 | 0.154707 |
7 | 2 | 0.343459 | 0.838657 | 3.259667e-05 | 0.117964 |
8 | 3 | 0.188918 | 0.463060 | 2.592787e-02 | 0.035690 |
9 | 4 | 0.140227 | 0.345719 | 1.009161e-01 | 0.019664 |
10 | 5 | 0.108444 | 0.268907 | 2.071656e-01 | 0.011760 |
plot_line_chart(use_data.index,use_data['新开工房TTM环比'],use_data['房销售面积TTM环比'],'房屋新开工面积:TTM环比','商品房销售面积:TTM环比')
chart_xkg_fxs = calculate_lag(use_data,'新开工房TTM环比','房销售面积TTM环比')
chart_xkg_fxs
领先期 | 相关系数 | 回归系数 | P值 | R方 | |
---|---|---|---|---|---|
0 | -5 | 0.439651 | 0.523825 | 7.653033e-08 | 0.193293 |
1 | -4 | 0.430737 | 0.512420 | 1.338582e-07 | 0.185534 |
2 | -3 | 0.420003 | 0.499698 | 2.645205e-07 | 0.176403 |
3 | -2 | 0.309651 | 0.368403 | 1.969272e-04 | 0.095884 |
4 | -1 | 0.253768 | 0.303059 | 2.394450e-03 | 0.064398 |
5 | 0 | 0.369778 | 0.440596 | 5.924863e-06 | 0.136736 |
6 | 1 | 0.147222 | 0.175434 | 8.149016e-02 | 0.021674 |
7 | 2 | 0.070530 | 0.085811 | 4.076314e-01 | 0.004974 |
8 | 3 | 0.058054 | 0.070915 | 4.972431e-01 | 0.003370 |
9 | 4 | -0.070280 | -0.086537 | 4.127221e-01 | 0.004939 |
10 | 5 | -0.101976 | -0.126894 | 2.357181e-01 | 0.010399 |
plot_line_chart_double_yaxis(use_data.index,use_data['房销售面积TTM环比'],use_data['钢材消费量TTM环比'],'商品房销售面积:TTM环比','钢材消费量:TTM环比')
chart_fxs_gxf = calculate_lag(use_data,'房销售面积TTM环比','钢材消费量TTM环比')
chart_fxs_gxf
领先期 | 相关系数 | 回归系数 | P值 | R方 | |
---|---|---|---|---|---|
0 | -5 | 0.036177 | 0.071470 | 6.747085e-01 | 0.001309 |
1 | -4 | 0.156861 | 0.312623 | 6.616168e-02 | 0.024605 |
2 | -3 | 0.273446 | 0.549670 | 1.125678e-03 | 0.074773 |
3 | -2 | 0.374056 | 0.753450 | 5.298867e-06 | 0.139918 |
4 | -1 | 0.514016 | 1.053551 | 7.075580e-11 | 0.264213 |
5 | 0 | 0.600553 | 1.224321 | 2.788067e-15 | 0.360664 |
6 | 1 | 0.631484 | 1.288070 | 4.655938e-17 | 0.398772 |
7 | 2 | 0.610734 | 1.247909 | 1.127121e-15 | 0.372995 |
8 | 3 | 0.573210 | 1.175172 | 1.651489e-13 | 0.328570 |
9 | 4 | 0.496066 | 1.023276 | 6.133997e-10 | 0.246081 |
10 | 5 | 0.440559 | 0.912868 | 7.143625e-08 | 0.194092 |
plot_line_chart_double_yaxis(use_data.index,use_data['竣工房TTM环比'],use_data['钢材消费量TTM环比'],'房屋竣工面积:TTM环比','钢材消费量:TTM环比')
chart_jgf_gxf = calculate_lag(use_data,'竣工房TTM环比','钢材消费量TTM环比')
chart_jgf_gxf
领先期 | 相关系数 | 回归系数 | P值 | R方 | |
---|---|---|---|---|---|
0 | -5 | 0.039678 | 0.064767 | 0.645266 | 0.001574 |
1 | -4 | -0.019928 | -0.032464 | 0.816546 | 0.000397 |
2 | -3 | -0.007979 | -0.012993 | 0.925729 | 0.000064 |
3 | -2 | -0.038046 | -0.061846 | 0.655386 | 0.001447 |
4 | -1 | 0.008400 | 0.013662 | 0.921246 | 0.000071 |
5 | 0 | 0.104532 | 0.168999 | 0.215708 | 0.010927 |
6 | 1 | 0.079987 | 0.129620 | 0.345758 | 0.006398 |
7 | 2 | 0.164041 | 0.265412 | 0.052782 | 0.026910 |
8 | 3 | 0.145610 | 0.236506 | 0.087202 | 0.021202 |
9 | 4 | 0.173375 | 0.282578 | 0.041992 | 0.030059 |
10 | 5 | 0.174423 | 0.285966 | 0.041499 | 0.030423 |
plot_line_chart(use_data.index,use_data['固投TTM环比'],use_data['钢材消费量TTM环比'],'固定投资完成额:TTM环比','钢材消费量:TTM环比')
chart_gt_gxf = calculate_lag(use_data,'固投TTM环比','钢材消费量TTM环比')
chart_gt_gxf
领先期 | 相关系数 | 回归系数 | P值 | R方 | |
---|---|---|---|---|---|
0 | -5 | 0.244045 | 0.274462 | 0.004055 | 0.059558 |
1 | -4 | 0.261286 | 0.293987 | 0.001965 | 0.068270 |
2 | -3 | 0.314153 | 0.353506 | 0.000166 | 0.098692 |
3 | -2 | 0.347938 | 0.391230 | 0.000025 | 0.121061 |
4 | -1 | 0.361147 | 0.406961 | 0.000011 | 0.130427 |
5 | 0 | 0.384918 | 0.435056 | 0.000002 | 0.148162 |
6 | 1 | 0.369019 | 0.415936 | 0.000007 | 0.136175 |
7 | 2 | 0.338102 | 0.381084 | 0.000044 | 0.114313 |
8 | 3 | 0.320925 | 0.361044 | 0.000117 | 0.102993 |
9 | 4 | 0.301903 | 0.340731 | 0.000320 | 0.091145 |
10 | 5 | 0.311078 | 0.352965 | 0.000216 | 0.096770 |
plot_line_chart(use_data.index,use_data['基建TTM环比'],use_data['钢材消费量TTM环比'],'基础设施建设投资:TTM环比','钢材消费量:TTM环比')
chart_gt_gxf = calculate_lag(use_data,'基建TTM环比','钢材消费量TTM环比')
chart_gt_gxf
领先期 | 相关系数 | 回归系数 | P值 | R方 | |
---|---|---|---|---|---|
0 | -5 | -0.008419 | -0.011117 | 0.922218 | 0.000071 |
1 | -4 | 0.043222 | 0.057071 | 0.614712 | 0.001868 |
2 | -3 | 0.088951 | 0.117406 | 0.297732 | 0.007912 |
3 | -2 | 0.133310 | 0.175617 | 0.116363 | 0.017772 |
4 | -1 | 0.180527 | 0.238504 | 0.032179 | 0.032590 |
5 | 0 | 0.248761 | 0.328629 | 0.002834 | 0.061882 |
6 | 1 | 0.292400 | 0.387371 | 0.000434 | 0.085498 |
7 | 2 | 0.288777 | 0.383791 | 0.000540 | 0.083392 |
8 | 3 | 0.292671 | 0.390291 | 0.000472 | 0.085657 |
9 | 4 | 0.298607 | 0.400987 | 0.000374 | 0.089166 |
10 | 5 | 0.316240 | 0.426768 | 0.000167 | 0.100007 |
plot_line_chart(use_data.index,use_data['房地产投资TTM环比'],use_data['钢材消费量TTM环比'],'房地产投资完成额:TTM环比','钢材消费量:TTM环比')
chart_gt_gxf = calculate_lag(use_data,'房地产投资TTM环比','钢材消费量TTM环比')
chart_gt_gxf
领先期 | 相关系数 | 回归系数 | P值 | R方 | |
---|---|---|---|---|---|
0 | -5 | 0.521876 | 0.627477 | 6.164546e-11 | 0.272354 |
1 | -4 | 0.486885 | 0.584353 | 1.402242e-09 | 0.237057 |
2 | -3 | 0.488694 | 0.586285 | 1.037837e-09 | 0.238821 |
3 | -2 | 0.484789 | 0.580433 | 1.282120e-09 | 0.235020 |
4 | -1 | 0.477737 | 0.569918 | 2.093674e-09 | 0.228233 |
5 | 0 | 0.455423 | 0.543601 | 1.236175e-08 | 0.207410 |
6 | 1 | 0.395263 | 0.471935 | 1.230126e-06 | 0.156233 |
7 | 2 | 0.330166 | 0.395118 | 6.780456e-05 | 0.109010 |
8 | 3 | 0.227008 | 0.272194 | 7.201134e-03 | 0.051533 |
9 | 4 | 0.170021 | 0.204532 | 4.618849e-02 | 0.028907 |
10 | 5 | 0.121208 | 0.146595 | 1.582706e-01 | 0.014691 |
plot_line_chart_double_yaxis(use_data.index,use_data['汽车产量TTM环比'],use_data['钢材消费量TTM环比'],'汽车产量:TTM环比','钢材消费量:TTM环比')
chart_gt_gxf = calculate_lag(use_data,'汽车产量TTM环比','钢材消费量TTM环比')
chart_gt_gxf
领先期 | 相关系数 | 回归系数 | P值 | R方 | |
---|---|---|---|---|---|
0 | -5 | 0.427195 | 0.748433 | 1.928531e-07 | 0.182495 |
1 | -4 | 0.525598 | 0.920078 | 3.611841e-11 | 0.276253 |
2 | -3 | 0.634736 | 1.111433 | 4.846082e-17 | 0.402890 |
3 | -2 | 0.724027 | 1.272897 | 5.128554e-24 | 0.524216 |
4 | -1 | 0.736949 | 1.303056 | 2.077786e-25 | 0.543094 |
5 | 0 | 0.785624 | 1.382278 | 5.478489e-31 | 0.617205 |
6 | 1 | 0.690908 | 1.219318 | 2.525497e-21 | 0.477354 |
7 | 2 | 0.648352 | 1.147791 | 4.710913e-18 | 0.420361 |
8 | 3 | 0.545613 | 0.968759 | 3.766158e-12 | 0.297693 |
9 | 4 | 0.461471 | 0.824318 | 1.222477e-08 | 0.212955 |
10 | 5 | 0.346763 | 0.622978 | 3.308526e-05 | 0.120245 |
plot_line_chart_double_yaxis(use_data.index,use_data['M2'],use_data['钢材消费量TTM环比'],'M2','钢材消费量:TTM环比')
chart_gt_gxf = calculate_lag(use_data,'M2','钢材消费量TTM环比')
chart_gt_gxf
领先期 | 相关系数 | 回归系数 | P值 | R方 | |
---|---|---|---|---|---|
0 | -5 | 0.439704 | 246.609769 | 7.622284e-08 | 0.193339 |
1 | -4 | 0.531815 | 298.147224 | 1.920301e-11 | 0.282828 |
2 | -3 | 0.606799 | 340.547427 | 2.420984e-15 | 0.368205 |
3 | -2 | 0.674200 | 378.166519 | 6.840686e-20 | 0.454546 |
4 | -1 | 0.728889 | 407.935127 | 1.238320e-24 | 0.531279 |
5 | 0 | 0.761632 | 424.306728 | 3.678241e-28 | 0.580083 |
6 | 1 | 0.770310 | 426.816460 | 6.021124e-29 | 0.593378 |
7 | 2 | 0.769847 | 424.547981 | 1.069960e-28 | 0.592665 |
8 | 3 | 0.749096 | 411.007586 | 2.849955e-26 | 0.561145 |
9 | 4 | 0.720866 | 394.912805 | 2.087951e-23 | 0.519648 |
10 | 5 | 0.669588 | 366.094684 | 3.704375e-19 | 0.448349 |
经过前面的一番检验:
1.新开工房面积、房地产投资完成额都是钢材表观消费量的滞后指标
2.固定资产投资完成额、汽车产量与钢材表观消费量基本同步
3.商品房销售面积,基础设施建设投资、M2为钢材表观消费量的领先指标,领先期分别为1~2个月,3~5个月,1~2个月
因此,对于钢铁表观消费量的预测,可以使用商品房销售面积、基础设施建设投资、M2为使用变量
###以前一年数据作为样本进行滚动回归,得到回归系数,以此系数预测下一个月钢材表观消费量TTM环比增速
###商品房销售面积、基础设施建设投资、M2的领先期分别选为2个月、4个月、2个月
testdata = use_data[['钢材消费量TTM环比','房销售面积TTM环比','基建TTM环比','M2']]
def predict_TTM_growth(testdata,y_var,x_var,x_lag,regre_period = 12):
x_var_lag = []
for x,lag in zip(x_var,x_lag):
testdata[x+'_lag'+str(lag)] = testdata[x].shift(lag)
x_var_lag.append(x+'_lag'+str(lag))
use_testdata = testdata[[y_var] + x_var_lag]
use_testdata.dropna(inplace=True)
use_testdata[y_var+'_预测'] = np.NaN
corr_chart = use_testdata[x_var_lag].corr()
print (corr_chart)
for i in range(regre_period,len(use_testdata)):
train_data = use_testdata[i-regre_period:i]
y = train_data[y_var]
x = train_data[x_var_lag]
x = sm.add_constant(x)
est = sm.OLS(y,x)
results = est.fit()
predict_data = use_testdata[i:i+1]
predict_x = predict_data[x_var_lag]
predict_x = sm.add_constant(predict_x)
use_testdata.iloc[i,-1] = results.predict(predict_x)
return use_testdata
predict_data = predict_TTM_growth(testdata,'钢材消费量TTM环比',['房销售面积TTM环比','基建TTM环比','M2'],[2,4,2])
plot_line_chart(predict_data.index,predict_data['钢材消费量TTM环比'],predict_data['钢材消费量TTM环比_预测'],'钢材消费量TTM环比','钢材消费量TTM环比预测')
/opt/conda/lib/python3.4/site-packages/ipykernel/__main__.py:5: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy /opt/conda/lib/python3.4/site-packages/ipykernel/__main__.py:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy /opt/conda/lib/python3.4/site-packages/ipykernel/__main__.py:9: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy /opt/conda/lib/python3.4/site-packages/pandas/core/indexing.py:115: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self._setitem_with_indexer(indexer, value)
房销售面积TTM环比_lag2 基建TTM环比_lag4 M2_lag2 房销售面积TTM环比_lag2 1.000000 0.198354 0.455816 基建TTM环比_lag4 0.198354 1.000000 0.419496 M2_lag2 0.455816 0.419496 1.000000
/opt/conda/lib/python3.4/site-packages/ipykernel/__main__.py:27: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
steel_price = steel_fd_data[['钢材价格综合指数']]
steel_price.fillna(method='ffill',inplace = True)
steel_price['钢材价格综合指数_lag2'] = steel_price['钢材价格综合指数'].shift(2)
steel_price['钢材价格综合指数_lag14'] = steel_price['钢材价格综合指数'].shift(14)
tdata = use_data[['钢材消费量TTM环比','房销售面积TTM环比','基建TTM环比','M2']]
###以前一年数据作为样本进行滚动回归,得到回归系数,以此系数预测下一个月钢材表观消费量TTM环比增速
testdata = pd.concat([tdata[['房销售面积TTM环比','基建TTM环比','M2']],\
steel_price[['钢材价格综合指数']],\
clean_data[['钢铁行业销售收入TTM_环比']][:-3]],axis=1)
predict_data_ = predict_TTM_growth(testdata,'钢铁行业销售收入TTM_环比',\
['房销售面积TTM环比','基建TTM环比','钢材价格综合指数','钢材价格综合指数','M2'],[2,4,2,14,2])
plot_line_chart(predict_data_.index,predict_data_['钢铁行业销售收入TTM_环比'],predict_data_['钢铁行业销售收入TTM_环比_预测'],\
'钢铁行业销售收入TTM_环比','钢铁行业销售收入TTM_环比_预测')
/opt/conda/lib/python3.4/site-packages/pandas/core/frame.py:2532: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy **kwargs) /opt/conda/lib/python3.4/site-packages/ipykernel/__main__.py:3: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy app.launch_new_instance() /opt/conda/lib/python3.4/site-packages/ipykernel/__main__.py:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy /opt/conda/lib/python3.4/site-packages/ipykernel/__main__.py:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy /opt/conda/lib/python3.4/site-packages/ipykernel/__main__.py:9: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy /opt/conda/lib/python3.4/site-packages/pandas/core/indexing.py:115: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self._setitem_with_indexer(indexer, value)
房销售面积TTM环比_lag2 基建TTM环比_lag4 钢材价格综合指数_lag2 钢材价格综合指数_lag14 \ 房销售面积TTM环比_lag2 1.000000 -0.082437 -0.004757 -0.185949 基建TTM环比_lag4 -0.082437 1.000000 0.029752 0.170184 钢材价格综合指数_lag2 -0.004757 0.029752 1.000000 0.514030 钢材价格综合指数_lag14 -0.185949 0.170184 0.514030 1.000000 M2_lag2 0.083721 0.225676 0.328398 0.690747 M2_lag2 房销售面积TTM环比_lag2 0.083721 基建TTM环比_lag4 0.225676 钢材价格综合指数_lag2 0.328398 钢材价格综合指数_lag14 0.690747 M2_lag2 1.000000
/opt/conda/lib/python3.4/site-packages/ipykernel/__main__.py:27: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
本社区仅针对特定人员开放
查看需注册登录并通过风险意识测评
5秒后跳转登录页面...
移动端课程