python对于excel数据按照标签进行分组处理
最近做的利用百度api对路线进行路径纠偏,由于本人实在小白遇到很多问题。
数据是这样的,其中imsi有八十个不同的。
对于路线纠偏的代码如下
import requestsurl = "http://api.map.baidu.com/rectify/v1/track? //POST请求"
payload = {'ak': 'GbYuGBxS0wBbNo7lmf4H8A51CPikHXaX',
'point_list':
'[{"coord_type_input":"bd09ll","loc_time":"1538469875","latitude":"41.51839828","longitude":"122.8960876"}, {"coord_type_input":"bd09ll","loc_time":"1538559097","latitude":"41.51839828","longitude":"122.8960876"}, {"coord_type_input":"bd09ll","loc_time":"1538559169","latitude":"41.51839828","longitude":"122.8960876"}, {"coord_type_input":"bd09ll","loc_time":"1538559200","latitude":"41.51839828","longitude":"122.8960876"}, {"coord_type_input":"bd09ll","loc_time":"1538560137","latitude":"41.51839828","longitude":"122.8960876"}, {"coord_type_input":"bd09ll","loc_time":"1538561315","latitude":"41.51470947","longitude":"122.8896332"}, {"coord_type_input":"bd09ll","loc_time":"1538561316","latitude":"41.51470947","longitude":"122.8896332"}, {"coord_type_input":"bd09ll","loc_time":"1538561798","latitude":"41.51470947","longitude":"122.8896332"}, {"coord_type_input":"bd09ll","loc_time":"1538561873","latitude":"41.51470947","longitude":"122.8896332"}, {"coord_type_input":"bd09ll","loc_time":"1538563008","latitude":"41.52077866","longitude":"122.9067917"}, {"coord_type_input":"bd09ll","loc_time":"1538565120","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538565308","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538566778","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538566796","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538567459","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538567647","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538568629","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538568718","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538569911","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538570363","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538570436","latitude":"41.51839828","longitude":"122.8960876"}, {"coord_type_input":"bd09ll","loc_time":"1538570526","latitude":"41.51839828","longitude":"122.8960876"}, {"coord_type_input":"bd09ll","loc_time":"1538571787","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538571908","latitude":"41.51762009","longitude":"122.8947372"}, {"coord_type_input":"bd09ll","loc_time":"1538576650","latitude":"41.79916","longitude":"123.40065"}, {"coord_type_input":"bd09ll","loc_time":"1538578125","latitude":"41.8078804","longitude":"123.4119873"}, {"coord_type_input":"bd09ll","loc_time":"1538578725","latitude":"41.8078804","longitude":"123.4119873"}, {"coord_type_input":"bd09ll","loc_time":"1538578740","latitude":"41.8078804","longitude":"123.4119873"}, {"coord_type_input":"bd09ll","loc_time":"1538579250","latitude":"41.8078804","longitude":"123.4119873"}, {"coord_type_input":"bd09ll","loc_time":"1538580687","latitude":"41.8078804","longitude":"123.4119873"}, {"coord_type_input":"bd09ll","loc_time":"1538582003","latitude":"41.80886078","longitude":"123.4087296"}, {"coord_type_input":"bd09ll","loc_time":"1538582146","latitude":"41.80886078","longitude":"123.4087296"}, {"coord_type_input":"bd09ll","loc_time":"1538508443","latitude":"41.51470947","longitude":"122.8896332"}]',
'rectify_option': 'need_mapmatch:1|transport_mode:auto|denoise_grade:2|vacuate_grade:1',
'supplement_mode': 'no_supplement',
'coord_type_output': 'bd09ll',
'extensions': 'base'}
files = [
]
headers = {
'Cookie': 'BAIDUID=3BD05070EA56816BB6FF7B088D3FC630:FG=1'
}
response = requests.request("POST", url, headers=headers, data = payload, files = files)
print(response.text.encode('utf8'))
new=open(r'A.txt','a')
new.write(response.text)
new.close()
但是这个只能将坐标点输入进去(而且百度api的要求是数据点不能过多),如果重复八十次实在是浪费人力,而且后期数据更多的时候更加无法操作。有没有方法能依次对不同的imsi用户进行以上操作,感觉还是有点复杂。
或者能不能将数据按照imsi输出成这样:
这样我一个一个输入也会方便一些,泪目
以上是 python对于excel数据按照标签进行分组处理 的全部内容, 来源链接: utcz.com/a/159881.html