Here is a very basic example of how to take the five columns and predict the next one (the 6th) for the first row of the data, using scikit-learn. pip install scikit-learn
if you have not got it.
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
data = { '2016/17' : [14.53, 14.52],
'2017/18' : [13.75,13.74],
'2018/19' : [13.03,13.03],
'2019/20' : [16.05,16.03],
'2020/21' : [15.15,15.14]}
df = pd.DataFrame(data)
X = np.array([[1],[2],[3],[4],[5]]) # dummy x values for each of the columns you are going to use as input data
Y = df.iloc[0,:].values.reshape(-1, 1) # work on row 0
linear_regressor = LinearRegression() # create object for the class
linear_regressor.fit(X, Y) # perform linear regression
prediction = linear_regressor.predict(np.array([[6]]))
Now you will have to take this and get it to work row wise and put the answer into the column you want but the basic machinery is all there.
You will also have to deal with the interesting problems of void. imputation
is what you need but it will be problematic if too much data is missing.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…