# -*- coding: utf-8 -*- import math import re import csv import repr def ean_checksum(eancode): """returns the checksum of an ean string of length 13, returns -1 if the string has the wrong length""" if len(eancode) != 13: re
import numpy as np import pandas as pd df = pd.DataFrame({'var1':np.random.rand(100), #生成100个0到1之间的随机数 'var2':100, 'var3':np.random.choice([20,30,90]) #在这几个数之间选择 } ) for col in df.columns: print("该列数据的均值位%.2f" %df[col].mean()) #计算每列均值 print(df['
转载解决写入csv中间隔一行空行问题 写入csv: with open(birth_weight_file,'w') as f: writer=csv.writer(f) writer.writerow(birth_header) writer.writerows(birth_data) f.close() 这种写法最终的结果就是生成的csv文件每两行中间都有一行空白行,解决办法就是写入后面加上newline='' 写法: with open(birth_weight_file,'w',newl