One - One Code All

Blog Content

python时间序列pandas计算涨跌幅

Python 智能投研 统计学-科学计算   2013-06-08 22:36:57

涨跌幅定义为今日收盘价减去昨日收盘价。(close_today - close_yesterday) / close_yesterday


利用 diff 函数快速计算涨跌幅。
# data
#rise = dataframe1.closing_price.diff()
rise = dataframe1['closing_price'].diff()
data['rise'] = rise
data.head()


上一篇:pandas常用统计方法
下一篇:pandas乘法DataFrame.multiply()

The minute you think of giving up, think of the reason why you held on so long.