jupyter notebook运行时间序列分解STL趋势和季节

栏目: 编程工具 · 发布时间: 7年前

1. "ImportError: No module named" when trying to run Python script

notebook不知道module的路径在哪,默认只知道current path

先找到包所在位置

pip show --verbose pandas

再告诉notebook

import sys

sys.path.append('/usr/local/lib/python2.7/dist-packages')

2.  安装分解时间序列用到的包

pip install statsmodels

3. AttributeError: 'Index' object has no attribute 'inferred_freq'

seasonal_decompose()对pandas Series需要是datetime

import pandas as pd

from pandas import Series

from matplotlib import pyplot

from statsmodels.tsa.seasonal import seasonal_decompose

df = pd.read_csv('data.csv', header=0)

df.Date = pd.to_datetime(df.Date,errors='coerce')

df = df.set_index('Date')

result = seasonal_decompose(df, model='mutiplicative',freq=7)

result.plot()

pyplot.show()

4. notebook显示图片太小,变大

import matplotlib.pyplot as plt

fig_size = [20, 9]

plt.rcParams["figure.figsize"] = fig_size

本文由safa 创作,采用 知识共享署名-相同方式共享 3.0 中国大陆许可协议 进行许可。

转载、引用前需联系作者,并署名作者且注明文章出处。

本站文章版权归原作者及原出处所有 。内容为作者个人观点, 并不代表本站赞同其观点和对其真实性负责。本站是一个个人学习交流的平台,并不用于任何商业目的,如果有任何问题,请及时联系我们,我们将根据著作权人的要求,立即更正或者删除有关内容。本站拥有对此声明的最终解释权。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Art of Computer Programming, Volume 4,  Fascicle 3

The Art of Computer Programming, Volume 4, Fascicle 3

Donald E. Knuth / Addison-Wesley Professional / 2005-08-05 / USD 19.99

Finally, after a wait of more than thirty-five years, the first part of Volume 4 is at last ready for publication. Check out the boxed set that brings together Volumes 1 - 4A in one elegant case, and ......一起来看看 《The Art of Computer Programming, Volume 4, Fascicle 3》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具