对数据的处理函数

zip函数把东西打包成一个以逗号为分隔的元组

weather_dict = dict(zip(regions, zip(weather_stations, region_names, cities)))
weather_dict
{'CAPITL': ('kalb', 'Capital', 'Albany'),'WEST': ('kpbg', 'North', 'Plattsburgh')}

Python 语言来编码和解码 JSON 对象,参考菜鸟教程例子以及农作物比赛的源码

从excel中导入数据到程序中:

df = pd.read_excel(r'C:Users27058Desktopprogram1.xlsx')

//df为pd对象,可直接以df[列名]来访问每条数据

df = df[['timestamp', 'name', 'ptid', 'load']]

//选取所得数据中的某几列

df.to_csv('../data/nyiso/all/combined_iso.csv', index=False)

//选的数据重新写入文件

format函数对字符串进行格式化处理,参考实例:http://www.runoob.com/python/att-string-format.html

对两个列表进行遍历,分别操作两个列表元素

1 >>> list1 = ['a', 'b', 'c', 'd']
2 >>> list2 = ['apple', 'boy', 'cat', 'dog']
3 >>> for x, y in zip(list1, list2):
4       print(x, 'is', y)
5 # 输出
6 a is apple
7 b is boy
8 c is cat
9 d is dog

 numpy.around(array,n) 函数对np数组元素取小数点后n位

例:

shu1_y_pre=np.around(shu1_y_pre,1)
原文地址:https://www.cnblogs.com/ywheunji/p/10083806.html