[Python] Read and plot data from csv file
Install:
pip install pandas
pip install matplotlib # check out the doc from site
import pandas as pd
import matplotlib.pyplot as plt
from numpy import mean def load_df(symbol):
return pd.read_csv("data/{0}.csv".format(symbol)) def get_max_close(symbol):
""" Return the maximum closing value for stock idicicated by symbol.
Note: Data for a stock is stored in file: data/<symbol>.csv
"""
df = load_df(symbol)
return df["Close"].max() def get_mean_volume(symbol):
df = load_df(symbol)
return mean(df['Volume']) def printAdjClose():
df = pd.read_csv('data/ibm.csv')
df[['Low', 'High']].plot()
plt.show() def test_run():
"""
Function called by Test Run
"""
for symbol in ['aapl', 'ibm']:
print("Max close")
print(symbol, get_max_close(symbol))
print("Mean Volume")
print(symbol, get_mean_volume(symbol)) if __name__ == "__main__":
test_run()
printAdjClose()
[Python] Read and plot data from csv file的更多相关文章
- HTML save data to CSV or excel
/********************************************************************************* * HTML save data ...
- python.pandas read and write CSV file
#read and write csv of pandasimport pandas as pd goog =pd.read_csv(r'C:\python\demo\LiaoXueFeng\data ...
- Python: Write UTF-8 characters to csv file
To use codecs, we can write UTF-8 characters into csv file import codecs with open('ExcelUtf8.csv', ...
- NetSuite SuiteScript 2.0 export data to Excel file(xls)
In NetSuite SuiteScript, We usually do/implement export data to CSV, that's straight forward: Collec ...
- Python:使用pymssql批量插入csv文件到数据库测试
并行进程怎么使用? import os import sys import time def processFunc(i): time.sleep(10-i) print i if __name__= ...
- 利用php CI force_download($filename, $data) 下载.csv 文件解决文件名乱码,文件内容乱码
利用php CI force_download($filename, $data) 下载.csv 文件解决文件名乱码,文件内容乱码 2014-07-31 12:53 1047人阅读 评论(0) 收藏 ...
- ogr2ogr: Export Well Known Text (WKT) for one feature to a CSV file
Perhaps you’re looking for this? ogr2ogr -f “CSV” “E:\4_GIS\NorthArkCartoData\UnitedStates\MO_wkt” “ ...
- 用Python对体积较大的CSV文件进行比较的经验
用Python对体积较大的CSV文件进行比较的经验 » 进化的测试 | 进化的测试 用Python对体积较大的CSV文件进行比较的经验 python Add comments 八 032010 ...
- SQL SERVER – Import CSV File Into SQL Server Using Bulk Insert – Load Comma Delimited File Into SQL Server
CSV stands for Comma Separated Values, sometimes also called Comma Delimited Values. Create TestTabl ...
随机推荐
- 洛谷P2770 航空路线问题 最小费用流
Code: #include<cstdio> #include<iostream> #include<algorithm> #include<vector&g ...
- 洛谷P2756 飞行员配对方案问题 网络流_二分图
Code: #include<cstdio> #include<queue> #include<vector> #include<cstring> #i ...
- WordPress开启伪静态
一.NGINX 的话在 domain.conf 的 server 增加代码: location / { try_files $uri $uri/ /index.php?$args; } 如果使用的是 ...
- Django之ORM的增删改查
一.添加表记录 对于单表有两种方式 # 添加数据的两种方式 # 方式一:实例化对象就是一条表记录 Frank_obj = models.Student(name ="海东",cou ...
- word中输入公式方案
如何开启word公式模式:“Alt”+"=" 1. 如何输入矩阵: 使用&链接行元素,@进行换行,空格键进行转换 如输出: 先开启公式模式:“Alt”+"=&qu ...
- ZOJ 1825 Compound Words
Compound Words Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on ZJU. Original ...
- POJ 2375 Cow Ski Area
Cow Ski Area Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. Original I ...
- hdoj Let the Balloon Rise
/*Let the Balloon Rise Problem Description Contest time again! How excited it is to see balloons ...
- zoj 3820 Building Fire Stations (二分+树的直径)
Building Fire Stations Time Limit: 5 Seconds Memory Limit: 131072 KB Special Judge Marjar ...
- less12 函数
less .x(1) { x:11 } .x(2) { y:22 } .x(@x:1) when (default()) {z:@x} //default()表示一直为真 body{ backgrou ...