Skip to content

Instantly share code, notes, and snippets.

@WouterNieuwerth
Created February 9, 2020 13:43
Show Gist options
  • Save WouterNieuwerth/951c3c410dedd551c6a1782a93aca5d3 to your computer and use it in GitHub Desktop.
Save WouterNieuwerth/951c3c410dedd551c6a1782a93aca5d3 to your computer and use it in GitHub Desktop.
GPX analysis - step 4
# Create a column with values that are 'shifted' one forwards, so we can create calculations for differences.
df['lon-start'] = df['lon']
df['lon-start'].iloc[-1] = np.nan
df['lon-start'] = np.roll(df['lon-start'], 1)
df['lat-start'] = df['lat']
df['lat-start'].iloc[-1] = np.nan
df['lat-start'] = np.roll(df['lat-start'], 1)
df['alt-start'] = df['alt']
df['alt-start'].iloc[-1] = np.nan
df['alt-start'] = np.roll(df['alt-start'], 1)
df['time-start'] = df['time']
df['time-start'].iloc[-1] = np.nan
df['time-start'] = np.roll(df['time-start'], 1)
df = df.fillna(method='bfill')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment