나는 주식 틱 데이터를 다루기 위해 pandas와 함께 python을 사용하고 있으며 낮, 최고, 최저, 평균 25 %의 전체 볼륨으로 압축하려고합니다. 무역 볼륨의 75 %. 나는 25 %와 75 % 수준이 어디에 있는지를 찾는 방법을 확신하지 못합니다.Python pandas가 중간을 찾는다
#Refrences
from time import *
import urllib.request as web
import pandas as pd
import os
dateToday = "2014-10-31"
def pullData(exchange,stock,date):
baseUrl='http://netfonds.no/quotes/tradedump.php?csv_format=csv'
fullUrl=baseUrl+'&date='+date.replace("-","")+'&paper='+stock+'.'+exchange
fileName=('netfonds/trades/'+stock+'.txt')
try:
if not os.path.isdir(os.path.dirname(fileName)):
os.makedirs(os.path.dirname(fileName))
except OSError:
print("Directory Error")
#print(fullUrl)
webBuffer=web.urlopen(fullUrl)
webData=pd.read_csv(webBuffer,usecols=['price','quantity'])
low = webData['price'].min()
high = webData['price'].max()
print(low,high)
def getList(fileName):
stockList = []
file = open(fileName+'.txt', 'r').read()
fileByLines = file.split('\n')
for eachLine in fileByLines:
if '#' not in eachLine:
lineByValues = eachLine.split('.')
stockList.append(lineByValues)
return stockList
def fromList():
print("Parsing stock tickers...")
stockList = getList('stocks')
print("Found "+str(len(stockList))+" stocks")
for eachEntry in stockList:
start_time = time()
try:
print("Attempting to pull data for "+eachEntry[1])
pullData(eachEntry[0],eachEntry[1],dateToday)
print("Pulled succcessfully in "+str(round(time()-start_time))+" seconds")
except Exception:
print("Unable to pull data... "+eachEntry[1])
first_time = time()
fromList()
print("Program Finished! Took "+str(round((time()-first_time)/60))+' minutes')
스택 오버 플로우에 오신 것을 환영합니다! 당신이 작성한 코드를 게시 할 수 있습니까? – tsnorri
감사합니다. 지금까지 코드를 추가했습니다. –
['describe'] (http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.describe.html#pandas.DataFrame.describe) 이미 이것을 수행합니다 – EdChum