首页 > 其他 > 详细

处理时间序列数据

时间:2020-03-08 13:00:59      阅读:73      评论:0      收藏:0      [点我收藏+]

time series

时间序列数据就是随着时间发展变化(不变化)的数据

时间序列图

可以画共轴的子图,查看多个属性随时间变化的趋势

# Plot the time series in each dataset
fig, axs = plt.subplots(2, 1, figsize=(5, 10))
data.iloc[:1000].plot(y='data_values', ax=axs[0])
data2.iloc[:1000].plot(y='data_values', ax=axs[1])
plt.show()

技术分享图片

我再一次复习pd[[]]可以同时提取数据框的子集

*双中括号提取子列**

from sklearn.svm import LinearSVC

# Construct data for the model
X = data[["petal length (cm)" , "petal width (cm)"]]
y = data[['target']]

# Fit the model
model = LinearSVC()
model.fit(X, y)

还有就是想画在一个图的,公用y轴,如上述

reshape
给定数组或者数据框一个新的形状而不改变数据

其中常见的就是reshape(-1,1):数据集可以变成一列,之前matlab处理图像时候也有一个函数,忘记叫啥了,把像素归为一列

predict

一般拟合完模型,进行预测,可直接使用predict

glob

glob模块的主要方法就是glob,该方法返回所有匹配的文件路径列表(list);该方法需要一个参数用来指定匹配的路径字符串(字符串可以为绝对路径也可以为相对路径),其返回的文件名只包括当前目录里的文件名,不包括子文件夹里的文件。

librosa

librosa是一个非常强大的python语音信号处理的第三方库cnblog

import librosa as lr
from glob import glob

# List all the wav files in the folder
audio_files = glob(data_dir + '/*.wav')

# Read in the first audio file, create the time array
audio, sfreq = lr.load(audio_files[0])
time = np.arange(0, len(audio)) / sfreq

# Plot audio over time
fig, ax = plt.subplots()
ax.plot(time, audio)
ax.set(xlabel='Time (s)', ylabel='Sound Amplitude')
plt.show()

{{uploading-image-900268.png(uploading...)}}

处理时间序列数据

原文:https://www.cnblogs.com/gaowenxingxing/p/12441388.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!