使用熊猫数据框进行时间序列预测

时间:2020-11-06 05:51:31

标签: python pandas dataframe

我对熊猫数据帧预测非常陌生。我有一个简单的数据框,如下所示:

enter image description here

我希望在未来三年内预测fraction,例如2019、2020和2021。

到目前为止,我的代码如下:

df=pd.read_csv("by_tag_year.csv", index_col=None)
df

enter image description here

df['year'] = pd.to_datetime(df.year, format='%Y')
df['fraction'] = df ['number'] / df['year_total']
df.fraction = df.fraction.round(4)
programming_lang = ["r", "python", "c#", "java", "JavaScript", "php", "c++", "ruby", "Selenium"]
yearly_top = df[df['tag'].isin(programming_lang)]
sns.set(rc={'figure.figsize':(15,10)})
sns.lineplot(data=yearly_top, x='year', y='fraction', hue='tag')

enter image description here

yearly_python = df[df['tag']=='python']
yearly_python = yearly_python.iloc[: , [0, 4]].copy() 

yearly_python = yearly_python.filter(['year','fraction'], axis=1)
yearly_python

enter image description here

任何线索都将非常有帮助。我已经检查了此链接Forecasting with time series in python,但是它给了我一个错误'DataFrame' object has no attribute 'TimeSeries'

0 个答案:

没有答案