[英]Need to create a plot with panda series and numpy array
I have a panda time series (x) with time index t and numpy array (y) of same length. 我有一个具有相同长度的时间索引t和numpy数组(y)的熊猫时间序列(x)。 i need to create a plot of x,y on y axis and time (t) on x axis.
我需要在y轴上创建x,y图,在x轴上创建时间(t)。
x.shape (320,)
y.shape (320,1)
i tried converting numpy array but it gives me an error(Data must be 1-dimensional). 我尝试转换numpy数组,但它给了我一个错误(数据必须是一维的)。
pd.Series(y,index=x.index)
Assuming that your x
is a panda series and y
is a numpy array 假设您的
x
是熊猫系列,而y
是一个numpy数组
import matplotlib.pyplot as plt
plt.figure()
plt.plot(x.index.values, y, label="y")
plt.plot(x.index.values, x.value, label="x")
plt.legend()
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.