0
我有Pandas數據幀描述GPS數據,其中列表示軌跡索引,點索引(沿軌跡的點位置)和緯度/經度值(爲簡潔起見,顯示爲「xx」。從Pandas數據框中獲取序列
track point lat lon
1 1 xx xx
1 2 xx xx
1 3 xx xx
2 1 xx xx
2 2 xx xx
2 3 xx xx
... ... .. ..
我想辦法通過track
切片,然後排序point
。到目前爲止,我這樣做是在一個循環中,但我不知道這是正確的方式(我想沒有,因爲它似乎並不高效):
trks = getDataframe() //dataframe is created elsewhere
tracks = [] //this is what I want: some sequence of individual tracks
for trk in sorted(set(trks.trk)):
track = trks[(trks.track==trk)
track.sort(columns='point')
tracks.append(track)