I have code which is giving output in below format. How should i remove the first column and can store the elements of second row in list ? type of the output is in 'pandas.core.frame.DataFrame' format
speed lat lng
1 19.130506 12.616756 7.460664
2 63.595894 52.616838 7.460691
3 40.740044 72.616913 7.460718
4 22.227747 82.616993 7.460734
5 68.058223 12.617062 7.460758
Do you wanna use a values of speed like index?
if is that you can user set_index()
dataframe.set_index('speed', inplace=True)
to access the lat and lng elements you can do dataframe.loc[(speedvalue)] loc by example
dataframe.loc['19.130506']
Edit:
To transform all to a json
dataframe.set_index('speed', inplace=True).to_json(orient='index')
df = pd.DataFrame([
[19.130506 ,12.616756 ,7.460664],
[63.595894 ,52.616838 ,7.460691],
[40.740044 ,72.616913 ,7.460718],
[22.227747 ,82.616993 ,7.460734],
[68.058223 ,12.617062 ,7.460758]]
,columns=['speed', 'lat', 'lng']);
try this :
df.iloc[1:2,1:3].values.tolist().pop()
output :
[52.616838, 7.460691]
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.