python - Resample function works under Linux but not Windows -


i have use below python code deal timeserias data, file run under linux system, in widows can not run:

the featgen.py code below:

import os import sys import cpickle pickle import numpy np import pandas pd pandas import dataframe pprint import pprint import csv  import talib talib import abstract talib import common talib import func  featsel import feature_sel   class feature_gen():      ###############################################################################     def __init__(self, csv_path = './data/zjifmi201210-201410.csv', pkl_path = './data/data.pkl', resample_time = "10min"):         self.csv_path = csv_path         self.resample_time = resample_time         self.pkl_path = os.path.join("data", "data_{}.pkl".format(resample_time))      ###############################################################################     def feature_gen(self):         if os.path.exists(self.pkl_path):             print 'read data from:', self.pkl_path             data = pd.read_pickle(self.pkl_path)         else:             print 'read data from:', self.csv_path             lines = sum(1 _ in csv.reader(open(self.csv_path)))             rs_num = 10000             col_names = ['date', 'time', 'open', 'high', 'low', 'close', 'volume', 'adjust']             rs = pd.read_csv(                 self.csv_path,                 header = none,                 index_col = 0,                 names = col_names,                 parse_dates = {'timestamp':['date', 'time']},                 # skiprows = lines-rs_num             )             # print rs.head(10)             # print rs.tail(10)              #############################################################################             ## resample             if self.resample_time none:                 data = rs.ix[:, 0:5]                 # print data.shape # ohlcv                 save_pkl_path = os.path.split(self.pkl_path)[0]+'/data.pkl'             else:                 ***tt1 = rs.close.resample(self.resample_time, how = 'ohlc')***                 volume = rs.volume.resample(self.resample_time, how = 'sum')                 tt1['volume'] = volume                 data = tt1.dropna()                 # print data.shape # ohlcv                 print 'resample_time:', self.resample_time                 save_pkl_path = os.path.split(self.pkl_path)[0]+'/data_'+self.resample_time+'.pkl'                 print save_pkl_path              ##################################### feature selection #####################################             ###################################################################### need discuss             '''you can switch feature selection function here'''             data = feature_sel(data).feature_sel5()              ###############################################################################             # data = data.dropna()             # data = data.fillna(method="bfill")              ###############################################################################             open(save_pkl_path, "wb") fp:                 pickle.dump(data, fp)          ###############################################################################         # import pylab pl         # pl.plot(data.values[:, 3])         # pl.savefig("./data/close.png")          return data   if __name__ == '__main__':      '''first, search *pkl file, if not exist, search *csv file.'''     '''default parameters: csv_path = './data/zjifmi201210-201410.csv', pkl_path = './data/data.pkl', resample_time = none'''     data = feature_gen().feature_gen()     print data 

when run code under windows, returned below error:

file "c:\anaconda\sigming-task1-dev\featgen.py", line 57, in feature_gen tt1 = rs.close.resample(self.resample_time, how = 'ohlc') file "c:\anaconda\lib\site-packages\pandas\core\generic.py", line 3032, in resample return sampler.resample(self).finalize(self) file "c:\anaconda\lib\site-packages\pandas\tseries\resample.py", line 105, in resample raise typeerror('only valid datetimeindex, timedeltaindex or periodindex') typeerror: valid datetimeindex, timedeltaindex or periodindex

any suggestions?


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -