本文整理汇总了Python中DataLoader.load方法的典型用法代码示例。如果您正苦于以下问题:Python DataLoader.load方法的具体用法?Python DataLoader.load怎么用?Python DataLoader.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataLoader
的用法示例。
在下文中一共展示了DataLoader.load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_distance
# 需要导入模块: import DataLoader [as 别名]
# 或者: from DataLoader import load [as 别名]
def get_distance(directory) :
'''returns the distance in m'''
file = directory + '/info.dat'
info = dl.load(file)[0]
distancestr = info['Distance']
distance = 0.01*float(distancestr.replace('cm',''))
return distance
示例2: create_filename
# 需要导入模块: import DataLoader [as 别名]
# 或者: from DataLoader import load [as 别名]
def create_filename(directory, num=1) :
"""
creates basic name for a file containing condition and distance information.
Use num to assign numbers if more than one file per distance will be created
"""
file = directory + '/info.dat'
info = dl.load(file)[0]
distancestr = info['Distance']
conditionstr= info['Condition']
speciesName = 'Pholidoptera_littoralis_'
return speciesName+conditionstr+'_'+distancestr+'_'+str(num)
示例3: memory
# 需要导入模块: import DataLoader [as 别名]
# 或者: from DataLoader import load [as 别名]
###MAIN LOGIC
#get all stock symbols by reading csv names from data folder
symbols = []
#symbols = ['IVV','EEM','EFA','LQD','IYR','SHY','IEF','TIP']
symbols = ['VTI','EWJ','RWX','IEF','TLT','IAU','DBC','VGK','VNQ','VWO'] #quantopian list
allDfs = {}
#store all in memory (a dict of dfs). read from binary, if doesn't exist read from csv (and save binary)
for symbol in symbols:
if datetime.now().day in [31,1,2]:
forceDownload=True
else:
forceDownload=False
df= DataLoader.load(symbol,forceDownload=forceDownload)
shifted_dates = [(date+DateOffset(days=0)) for date in df.index] #shift dates to test path dependency
df.index = shifted_dates
allDfs[symbol] = df
#pdb.set_trace()
allClose = {}
#calculate rets
for symbol in symbols:
price = allDfs[symbol]['Adj Close']
prev_price = price.shift(1)
ret = price/prev_price-1
ret = Series(ret,index=price.index)
df=DataFrame({'RET':ret})
df2=DataFrame({'CLOSE':price})
allDfs[symbol] = df
示例4: memory
# 需要导入模块: import DataLoader [as 别名]
# 或者: from DataLoader import load [as 别名]
return performance_stats,cumrets, weights_df
###MAIN LOGIC
#get all stock symbols by reading csv names from data folder
symbols = []
#symbols = ['IVV','EEM','EFA','LQD','IYR','SHY','IEF','TIP']
#symbols = ['VTI','EWJ','RWX','IEF','TLT','IAU','DBC','VGK','VNQ','VWO'] #quantopian list
symbols = ['QRAAX','FDIVX','VTSMX','VGSIX','VFISX','VEIEX','VBMFX'] #mutual fund list
allDfs = {}
#store all in memory (a dict of dfs). read from binary, if doesn't exist read from csv (and save binary)
for symbol in symbols:
df= DataLoader.load(symbol)
shifted_dates = [(date+DateOffset(days=0)) for date in df.index] #shift dates to test path dependency
df.index = shifted_dates
allDfs[symbol] = df
#pdb.set_trace()
allClose = {}
#calculate rets
for symbol in symbols:
price = allDfs[symbol]['Adj Close']
prev_price = price.shift(1)
ret = price/prev_price-1
ret = Series(ret,index=price.index)
df=DataFrame({'RET':ret})
df2=DataFrame({'CLOSE':price})
allDfs[symbol] = df
示例5: memory
# 需要导入模块: import DataLoader [as 别名]
# 或者: from DataLoader import load [as 别名]
performance_stats['maxdd']=1-min(cumrets/cumrets.cummax())
return performance_stats,cumrets, weights_df
###MAIN LOGIC
#get all stock symbols by reading csv names from data folder
symbols = []
#symbols = ['IVV','EEM','EFA','LQD','IYR','SHY','IEF','TIP']
symbols = ['VTI','EWJ','RWX','IEF','TLT','IAU','DBC','VGK','VNQ','VWO'] #quantopian list
allDfs = {}
#store all in memory (a dict of dfs). read from binary, if doesn't exist read from csv (and save binary)
for symbol in symbols:
df= DataLoader.load(symbol,'20050101')
shifted_dates = [(date+DateOffset(days=0)) for date in df.index] #shift dates to test path dependency
df.index = shifted_dates
allDfs[symbol] = df
#pdb.set_trace()
#calculate rets
for symbol in symbols:
price = allDfs[symbol]['Adj Close']
prev_price = price.shift(1)
ret = price/prev_price-1
ret = Series(ret,index=price.index)
df=DataFrame({'RET':ret})
allDfs[symbol]=df
#pdb.set_trace()