Matplotlib candlestick TypeError: unsupported operand type(s) for -: 'str' and 'str'
Matplotlib candlestick TypeError: unsupported operand type(s) for -: 'str' and 'str'
我有一个Dataframe
格式如下:
Date Open Close High Low Volume
1 float float float float float int64
2 ...
3 ...
Date
为 float
天格式,其他所有内容(Volume
除外)均为 float
,已由 df.types
确认。
我把这个Dataframe
传给了一个matplotlib
.candlestick_ochl()
方法,如下:
import matplotlib.finance as mf
mf.candlestick_ochl(ax, df)
return 是 TypeError: unsupported operand type(s) for -: 'str' and 'str'
这让我觉得我不知何故得到了一个错误 candlestick_ochl()
试图减去两个字符串,但是在哪里?
In the traceback
the error arises from line 788 in finance.py _candlestick: height = close - open
感谢任何建议!
根据 tcaswell 的说明,我只是添加了以下更改:
MOCHLV = zip(df.Date, df.Open, df.Close, df.High, df.Low, df.Volume)
mf.candestick_ochl(ax, MOCHLV)
我有一个Dataframe
格式如下:
Date Open Close High Low Volume
1 float float float float float int64
2 ...
3 ...
Date
为 float
天格式,其他所有内容(Volume
除外)均为 float
,已由 df.types
确认。
我把这个Dataframe
传给了一个matplotlib
.candlestick_ochl()
方法,如下:
import matplotlib.finance as mf
mf.candlestick_ochl(ax, df)
return 是 TypeError: unsupported operand type(s) for -: 'str' and 'str'
这让我觉得我不知何故得到了一个错误 candlestick_ochl()
试图减去两个字符串,但是在哪里?
In the traceback
the error arises from line 788 in finance.py _candlestick:height = close - open
感谢任何建议!
根据 tcaswell 的说明,我只是添加了以下更改:
MOCHLV = zip(df.Date, df.Open, df.Close, df.High, df.Low, df.Volume)
mf.candestick_ochl(ax, MOCHLV)