This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_selected = df.loc[:, ['distance_dis_3d','time_delta']] | |
df_selected['distance_cumsum'] = df_selected['distance_dis_3d'].cumsum() | |
df_selected['time_cumsum'] = df_selected['time_delta'].cumsum() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculate distances and time deltas | |
df['distance_dis_2d'] = df.apply(lambda x: distance.distance((x['lat-start'], x['lon-start']), (x['lat'], x['lon'])).m, axis = 1) | |
df['alt_dif'] = df.apply(lambda x: x['alt-start'] - x['alt'], axis=1) | |
df['distance_dis_3d'] = df.apply(lambda x: sqrt(x['distance_dis_2d']**2 + (x['alt_dif'])**2), axis=1) | |
df['time_delta'] = df.apply(lambda x: (x['time'] - x['time-start']).total_seconds(), axis=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df['time'] = pd.to_datetime(df['time'], utc=True) | |
df['time'] = df['time'].dt.tz_localize(tz=None) | |
df['time-start'] = pd.to_datetime(df['time-start'], utc=True) | |
df['time-start'] = df['time-start'].dt.tz_localize(tz=None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for segment in gpx.tracks[0].segments: # all segments | |
data = segment.points | |
for point in data: | |
df = df.append({'lon': point.longitude, 'lat' : point.latitude, 'alt' : point.elevation, 'time' : point.time}, ignore_index=True) | |
df = df.sort_values(by=['time']) | |
df = df.reset_index() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All the sections you PB's for in meters: | |
sections = [1000,(1000*1.60934),3000,5000,(5000*1.60934),10000,15000,(10000*1.60934),20000,21097.5,25000,30000,40000,42195] | |
# The file you want to import: | |
file = 'my_run_001.gpx' | |
# This Pandas DataFrame will contain the final output of our analysis: | |
df_final = pd.DataFrame(columns=['time', 'distance', 'minutes_per_kilometer']) | |
gpx_file = open(file, 'r') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gpxpy | |
import matplotlib.pyplot as plt | |
import datetime | |
from geopy import distance | |
from math import sqrt, floor | |
import numpy as np | |
import pandas as pd | |
import haversine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function() { | |
// Rewrite of the Instant.page <html> snippet for Google Tag Manager. | |
var el = document.createElement('script'); | |
el.setAttribute('src', '//instant.page/1.2.2'); | |
el.setAttribute('type', 'module'); | |
el.setAttribute('integrity', 'sha384-2xV8M5griQmzyiY3CDqh1dn4z3llDVqZDqzjzcY+jCBCk/a5fXJmuZ/40JJAPeoU'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Loads the content of a Google Drive Spreadsheet into BigQuery | |
* Based on: | |
* - https://www.lunametrics.com/blog/2017/07/26/connect-google-analytics-data-tools-via-bigquery/ | |
* - https://developers.google.com/apps-script/advanced/bigquery | |
* Edit by Wouter Nieuwerth, [email protected] | |
* https://www.adwise.nl | |
*/ | |
function loadSpreadsheet() { |
NewerOlder