从excel文件中提取时间序列数据的python包。
xlseries的Python项目详细描述
从anyexcel中删除time series的python包 文件并将它们返回到pandasdata frames。
安装
如果要以开发人员模式安装,clone the repository并按照以下说明进行操作:
如果您使用Python作为您的python发行版
- conda create -n xlseries python=2创建新环境
- cd project_directory
- source activate xlseries激活环境
- pip install -e .以开发人员模式安装包
- pip install -r requirements.txt安装依赖项
- deactivate完成后停用
如果您使用的是标准的python安装
- cd project_directory
- virtualenv venv创建新环境
- source venv/bin/activate激活环境
- pip install -r requirements.txt安装依赖项
- deactivate完成后停用
如果您只想使用它:
pip install xlseries在您的环境中,而不是克隆和pip 以开发人员模式安装。
快速启动
fromxlseriesimportXlSeriesxl=XlSeries("path_to_excel_file"oropenpyxl.Workbookinstance)dfs=xl.get_data_frames("path_to_json_parameters"orparameters_dictionary)
使用1号测试用例:
fromxlseriesimportXlSeriesfromxlseries.utils.path_findersimportget_orig_cases_path,get_param_cases_path# this will only work if you clone the repo with all the test filespath_to_excel_file=get_orig_cases_path(1)path_to_json_parameters=get_param_cases_path(1)xl=XlSeries(path_to_excel_file)dfs=series.get_data_frames(path_to_json_parameters)
或者只将关键参数作为字典传递:
parameters_dictionary={"headers_coord":["B1","C1"],"data_starts":2,"frequency":"M","time_header_coord":"A1"}dfs=xl.get_data_frames(parameters_dictionary)
您可以指定要刮除的工作表(否则为第一个 将使用一个):
dfs=xl.get_data_frames(parameters_dictionary,ws_name="my_worksheet")
您可以向xlseries对象请求 需要填写的参数:
>>>params=xl.critical_params_template()>>>params{'data_starts':2,'frequency':'M','headers_coord':['B1','C1','E1-G1'],'time_header_coord':'A1'}>>>params["headers_coord"]=["B1","C1"]>>>dfs=xl.get_data_frames(params,ws_name="my_worksheet")
如果这不起作用,你想知道刮擦的确切位置 如果失败,您可能需要填写所有参数,然后重试 查看引发异常的位置:
>>>params=xl.complete_params_template()>>>params{'alignment':u'vertical','blank_rows':False,'continuity':True,'data_ends':None,'data_starts':2,'frequency':'M','headers_coord':['B1','C1','E1-G1'],'missing_value':[None,'-','...','.',''],'missings':False,'series_names':None,'time_alignment':0,'time_composed':False,'time_header_coord':'A1','time_multicolumn':False}>>>params["headers_coord"]=["B1","C1"]>>>params["data_ends"]=256>>>params["missings"]=True>>>dfs=xl.get_data_frames(params,ws_name="my_worksheet")
- excel文件:在此开发点之前,excel文件应该 不会比7 test cases:
- 参数:与excel文件一起,有关 必须提供系列。这些可以传给 以json文件或python的路径获取数据帧 字典。xlseries使用大约14个参数来描述 电子表格的时间序列,但其中只有4个是criticalmost 时间:剩下的可以通过包裹猜出来。唯一的 指定大于或小于4的参数之间的差异 critical是xlseries需要完成的总时间 任务(更多参数,更少时间)。有关详细信息,请转到parameters部分 解释如何使用它们,以及何时需要指定更多 比基本的4(headers_coord,data_starts,frequency 以及time_header_coord)。
看看这个ipython notebook template开始吧!.
如果您想深入了解测试用例并了解有多远 现在去xlseries,看看这个ipython notebook with the 7 test cases。
有关更多详细信息,请访问github上的官方存储库: https://github.com/abenassi/xlseries