Python - Numerical Statistics
来源:互联网 发布:sql数据库还原 编辑:程序博客网 时间:2024/05/18 22:42
# -*- coding: utf-8 -*-"""Created on Thu Apr 07 13:56:56 2016@author: wzhao3"""import jsonimport sysimport xlsxwriterimport globimport os#os.chdir("C:\\Users\\wzhao3\\Desktop\\CLV\\Shifu")#########################################def main(argv): if len(argv) <1: print "please input the stats target" return cat_set=[] with open("categorical.config") as cat_file: for line in cat_file: cat_set.append(line.rstrip('\n')) workbook = xlsxwriter.Workbook('Stat_numerical_Test.xlsx') worksheets=[] for arg in argv: worksheets.append(workbook.add_worksheet(arg)) for ws_index, ws in enumerate(worksheets): values=list() variables=[] header=['variable_name','sparkline'] for f_index, fileName in enumerate(sorted(glob.glob('files/ColumnConfig*.json'), key=lambda name: int(name.split('_')[1].split('.')[0]))): header.append(fileName.split('_')[1].split('.')[0]) with open(fileName) as data_file: data = json.load(data_file) content = [] for var in data: if var['columnName'] not in cat_set: if f_index==0: variables.append(var['columnName']) content.append(var['columnStats'][ws.get_name()]) values.append(content) header.append("STDEV") ws.write_row('A1', header) ws.write_column('A2', variables) ws.set_column('A:A', 20) ws.set_column('B:B', 50) values= map(list, zip(*values)) for i in range(len(values)): ws.write_row('C'+str(i+2), values[i]) for ws in worksheets: for i in range(len(variables)): ws.add_sparkline('B'+str(i+2), {'range': ws.get_name()+'!C'+str(i+2)+':'+ col(len(header)-1) +str(i+2) }) ws.write_formula(col(len(header))+str(i+2), '{=STDEV('+ws.get_name()+'!C'+str(i+2)+':'+ col(len(header)-1) +str(i+2)+')}' ) workbook.close()def col(n): if n<=26: return chr(65+n-1) if n>26 and n<=702: c1=int(n/26) c2=n%26 if c2==0: return chr(65+c1-2)+chr(65+26-1) else: return chr(65+c1-1)+chr(65+c2-1) if n>702 and n <= 17576: c1=n%26%26 c2=int(n/26) c3=c2%26 c4=int(c2/26) if c1==0: return chr(65+c4-1)+chr(65+c3-2)+chr(65+26-1) else: return chr(65+c4-1)+chr(65+c3-1)+chr(65+c1-1) if __name__ == "__main__": main(sys.argv[1:])
0 0
- Python - Numerical Statistics
- 重学statistics,Cha3 Descriptive Statistics: numerical measures
- Free Numerical, Mathematical, Statistics Libraries and Source Code
- numerical
- Numerical Methods in Engineering with Python
- Discover Python, Part 1: Python's built-in numerical types
- Discover Python, Part 1: Python's built-in numerical types
- Python数据分析包——NumPy(Numerical Python)
- Python统计模块statistics用法精要
- Probability And Statistics In Python: Linear Regression
- 统计处理包Statsmodels: statistics in python
- NUMERICAL ANALYSIS
- Numerical Bases
- Numerical Bases
- numerical optimization
- Numerical Circulation
- Numerical Integration
- Probability And Statistics In Python:Distributions And Sampling
- Defensive Programming in PHP(PHP中的防御性编程)
- 2.6 Python逻辑行与物理行
- opencv中窗口置顶的方法
- Mycat入门之Mycat安装
- Mongodb联合查询
- Python - Numerical Statistics
- Android 隐藏ScrollView的滚动条
- 【图像处理】SFR算法详解4
- 2.7 Python缩进
- gcd&exgcd O(∩_∩)O哈!
- HDG西安站|分享技术干货,打造开发者交流平台!
- 2.8 Python操作符
- (Arduino or NodeMcu) and PulseSensor and HTML
- ubuntu16.04下安装boost环境