I have dataframe like below:
miles uid
12 235
13 234
14 233
15 236
a list list1 like below:
[(39.14973, -77.20692),
(33.27569, -86.35877),
(42.55214, -83.18532),
(41.3278, -95.96396)]
The output dataframe I want
miles uid lat-long lat long
12 235 (39.14973, -77.20692) 39.14973 -77.20692
13 234 (33.27569, -86.35877) 33.27569 -86.35877
How can I achieve this
If length of DataFrame
is same like length of list first column only assign and for next 2 columns use list comprehension:
df['lat-long'] = list1
df['lat'] = [la for la, lo in list1]
df['lon'] = [lo for la, lo in list1]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.