内容简介:首先我们导入一些‘业界标准’库Pandas 里有两种常用的结构,一种叫
首先我们导入一些‘业界标准’库
import pandas as pd import numpy as np import talib as ta import matplotlib.pyplot as plt
Pandas 里有两种常用的结构,一种叫 DataFrame
,作为二维的一张表格;另一种叫 Series
,是一维数组。
DataFrame
取单行和单列得到的都是 Series
类型的对象。
追加数据
df = df.append(series, ignore_index=True)
获取最后一列数据
series = df.iloc[-1]
获取名为 close 的 column
series = df.close 或者 series = df['close']
取 series 中单个元素
close: float = series.close close: float = series['close']
series 转 list
series.list()
series 转 np array
np_array = np.array(series) 或 np_array = np.array(df.close) 或 np_array = np.array(df['close'])
结合 talib 计算
ta.RSI(np.array(bars.close))
可视化
df = pd.DataFrame({
'close': ... ,
'open': ... ,
'high': ... ,
'low': ... ,
'timestamp', ...
})
# figure 1
df.plot(x='timestamp', y=['close', 'high', 'low']) # 展示 close high low 三个属性
# figure 2
df.plot(x='timestamp') # 展示全部属性
# 展示上面两幅绘制过的图
plt.show()
Over
以上所述就是小编给大家介绍的《pandas的一些基础用法》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- AWK基础用法
- Java基础——Super用法
- SQL语句基础用法大全(DML)
- Go基础系列:双层channel用法示例
- 数据仓库组件:Hive 环境搭建和基础用法
- Java 基础:日期与时间 API 用法详解
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Web Security Testing Cookbook
Paco Hope、Ben Walther / O'Reilly Media / 2008-10-24 / USD 39.99
Among the tests you perform on web applications, security testing is perhaps the most important, yet it's often the most neglected. The recipes in the Web Security Testing Cookbook demonstrate how dev......一起来看看 《Web Security Testing Cookbook》 这本书的介绍吧!