有一个Pandas DataFrame:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 300 entries, 5220 to 5519
Data columns (total 3 columns):
Date 300 non-null datetime64[ns]
A 300 non-null float64
B 300 non-null float64
dtypes: datetime64[ns](1), float64(2)
memory usage: 30.5 KB
Run Code Online (Sandbox Code Playgroud)
我想绘制A和B系列与日期的关系.
plt.plot_date(data['Date'], data['A'], '-')
plt.plot_date(data['Date'], data['B'], '-')
Run Code Online (Sandbox Code Playgroud)
然后我想在A和B系列之间的区域上应用fill_between():
plt.fill_between(data['Date'], data['A'], data['B'],
where=data['A'] >= data['B'],
facecolor='green', alpha=0.2, interpolate=True)
Run Code Online (Sandbox Code Playgroud)
哪个输出:
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs
could not be safely coerced to any supported types according to the casting
rule ''safe''
Run Code Online (Sandbox Code Playgroud)
matplotlib是否在 …
有一个带有一些股票数据的Pandas DataFrame对象.SMA是从之前45/15天计算的移动平均线.
Date Price SMA_45 SMA_15
20150127 102.75 113 106
20150128 103.05 100 106
20150129 105.10 112 105
20150130 105.35 111 105
20150202 107.15 111 105
20150203 111.95 110 105
20150204 111.90 110 106
Run Code Online (Sandbox Code Playgroud)
当SMA_15和SMA_45相交时,我想找到所有日期.
可以使用Pandas或Numpy有效地完成吗?怎么样?
编辑:
我的意思是'十字路口':
数据行,时间:
我一直在关注官方的Kivy PongApp教程(链接 - 网站底部的整个程序代码),我遇到了一个我无法理解的问题.
我已经定义了移动功能,通过每帧上的速度矢量来改变球的位置.代码:
def move(self):
self.pos = Vector(*self.velocity) + self.pos
Run Code Online (Sandbox Code Playgroud)
但是,当我编写这样的代码时:
def move(self):
self.pos = self.pos + Vector(*self.velocity)
Run Code Online (Sandbox Code Playgroud)
它会导致错误:ValueError:PongBall.pos值长度是不可变的
为什么,它不应该是一样的吗?
我有Pandas DataFrame对象,包括Date,Open,Close,Low和High每日股票数据.我想计算Ichimoku图表的组件.我可以使用以下代码获取我的数据:
high_prices = data['High']
close_prices = data['Close']
low_prices = data['Low']
dates = data['Date'] # contains datetime objects
Run Code Online (Sandbox Code Playgroud)
我需要计算以下系列(Ichimoku称之为Tenkan-Sen系列):
(9期高+ 9期低)/ 2

我在这里找到了R语言的解决方案,但是我很难将其翻译成Python/Pandas代码.
Ichimoku图表包含更多组件,但是当我知道如何计算Pandas中的Tenkan-Sen系列时,我将能够计算所有这些(我将共享代码).