python - 'float' object has no attribute '__getitem__' in for loop -
so want extract gps coordinates column in pandas dataframe, single command line works perfect here, example, 6 can replaced other integers:
input: crimedata['geolocation'][6][-12:-1] output: '(30.42437, -91.051507' once coord strings out of bulk string, can edit more precisely want, wrote loop extract gps coordinates 320904 lines of strings,
lat_coord=[] long_coord=[] in range(0, 320904): lat_coord.append(crimedata['geolocation'][i][-22:-13]) long_coord.append(crimedata['geolocation'][i][-12:-1]) print lat_coord, long_coord and got error:
typeerror: 'float' object has no attribute '__getitem__' it looks [i] causing trouble, don't know how fix it. i'd appreciate inputs. many thanks!
here structure of column contains strings want extract gps coordinnates from:
0 7234 airline hw\nbaton rouge, la\n(30.482565, ... 1 5900 peerless st\nbaton rouge, la\n(30.516849,... 2 10250 plaza americana dr\nbaton rouge, la 7081... 3 964 n 48th\nbaton rouge, la 70802\n(30.457107,... 4 5950 st gerard av\nbaton rouge, la 70805\n(30.... 5 11111 coursey bl\nbaton rouge, la 70816\n(30.4... 6 3121 s sherwood forest bl\nbaton rouge, la\n(3... 7 2520 plank rd\nbaton rouge, la 70805\n(30.4705... 8 4414 tupello st\nbaton rouge, la 70808\n(30.41... ..... 320904 1253 florida st\nbaton rouge, la 70802\n(30.44... name: geolocation, dtype: object
Comments
Post a Comment