pcmiler包装python包
pcmiler的Python项目详细描述
pcmiler公司
一个python包,用于充分利用PCMiler产品。在
安装
pip install pcmiler
BatchPro配置
配置是根据输入数据格式和计算机上的PCMiler BatchPro安装设置的。pcmiler
将在c:
驱动器中搜索batchw32.exe
。如果找到,它将根据路径配置设置。否则,defualt设置将设置为以下值:
exe: "C:/ALK Technologies/<PCMILER VERSION DIR>/Batchpro/batchw32.exe" infile: "C:/ALK Technologies/<PCMILER VERSION DIR>/Batchpro/df.IN" cfgfile: "C:/ALK Technologies/<PCMILER VERSION DIR>/Batchpro/df.CFG" outfile: "C:/ALK Technologies/<PCMILER VERSION DIR>/Batchpro/df.OUT" logfile: "C:/ALK Technologies/<PCMILER VERSION DIR>/Batchpro/df.LOG" origin: origin_city: "origin_city" origin_state: "origin_state" origin_street: "origin_street" origin_zipcode: "origin_zipcode" origin_country: "origin_country" destination: dest_city: "dest_city" dest_state: "dest_state" dest_street: "dest_street" dest_zipcode: "dest_zipcode" dest_country: "dest_country" strfmt: "1, omax, omax + 2, dmax + 2, max_city_len"
有关可用产品和许可信息的更多信息,请参见pcmiler.com/about。您的计算机上必须安装了PCMiler BatchPro才能使用pcmiler
。在
BatchPro和pandas
^{pr2}$
您可以使用pcmiler.batchpro.config
或pcmiler.batchpro.update_config()
更新这些设置。在
frompcmilerimportbatchpro# tweak default configconfig=batchpro.config(origin={"city":"new col"})# update configconfig=batchpro.update_config(config,{"exe":""})df["miles"]=batchpro.miles_series(df=df,config=config)
使用您的config
获得更多控制。在
config=batchpro.config(exe="",# path to .exeinfile="",# path to .INcfgfile="",# path to .cfgorigin={"city":"","state":"","street":"","zipcode":"","country":""},destination={"city":"","state":"","street":"","zipcode":"","country":""},# character positions for [ostart, oend, dstart, dend, max_city_len]# without config it defaults to [1, omax, omax + 2, omax + dmax + 2, city length]# NOTE: " " separates origin strings from destination stringsstrfmt=[],)df["miles"]=batchpro.miles_series(df=df,config=config)
另一种方法是
frompcmilerimportbatchproorigins=batchpro.locstr_series(df,zip_col="origin_zip",address_cols=["origin_city","origin_state","origin_street"])dests=batchpro.locstr_series(df,zip_col="dest_zip",address_cols=["dest_city","dest_state","dest_street"])df["miles"]=batchpro.miles_series(origins=origins,destinations=dests)
最小输入数据
BatchPro需要的最小数据是City State或Zipcode。建议添加Country。在
pcmiler.batchpro.search_for_exe(_dir: str = "c:/")
pcmiler.batchpro.search_for_exe()
用于搜索完整的batchw32.exe
路径。如果没有提供配置,默认行为是在c:
驱动器中执行搜索。如果找不到,则使用C:/ALK Technologies/<PCMILER VERSION DIR>/Batchpro/batchw32.exe
。在
csv和excel文件的CLI
在当前工作目录中创建pcmiler.yaml
。完整的配置是将(#18)通过这种方法也将可用。在
exe:"path/to/batchw32.exe"sheet:"sheetnameifexcel"origin:zipcode:"zipcodecolumnname"city:"citycolumnname"state:"statecolumnname"street:"streetcolumnname"destination:zipcode:"zipcodecolumnname"city:"citycolumnname"state:"statecolumnname"street:"streetcolumnname"
运行pcmiler path/to/file
。您也可以运行pcmiler-gui
来手动选择一个文件。在
更多cli
--create-yaml
在当前工作目录中创建pcmiler.yaml
。在--debug
.日志摘要
请参阅Batchpro的.LOG
文件中的运行统计信息和设置。在
$ pcmiler batch.csv 11/14/2020 06:27:58 PM | found c:\ALK Technologies\PCMILER29\Batchpro\batchw32.exe 11/14/2020 06:27:58 PM | preparing batch.csv 11/14/2020 06:27:58 PM | running Batchpro 11/14/2020 06:28:02 PM | --SUMMARY STATISTICS-- Chunk Size : 2000 Calculated Sort Size : 80000 SortChunk on=1 off=0 : 1 Started Processing : Sat Nov 14 18:28:01 2020 Finished Processing : Sat Nov 14 18:28:02 2020 Total Processing Time : 0:00:01 Total number of O/D pairs : 2 Number of O/D pairs processed : 2 Number of errors : 0 Number of routes successfully run: 2 Number of pairs/second : 2.00 In File Format : PCMSave, 1, 34, 36, 70, 40 -----USER OPTIONS----- Region - NA Route Type - Practical Reports - Out City/Zip Routing - Use Local Streets Additional Options - Borders Open FavorOneWayDivided- Yes Distance Units - Miles 11/14/2020 06:28:02 PM | saving results to C:\Users\pryerc\github\pcmiler\tests\pcmiler-batch.csv
- 项目
标签: