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
# ------------- | |
# Imports | |
from stravalib.client import Client | |
import pprint | |
# ------------- | |
# Get a certain activity | |
client = Client(access_token='I-AM-THE-TOKEN') | |
activity = client.get_activity(1234567890) |
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
# ------------- | |
# Imports | |
import pandas as pd | |
pd.set_option("display.max_columns", 100) | |
import pprint | |
from stravalib.client import Client | |
# ------------- |
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
## with plotly.express | |
fig_2 = px.line(gpx_df, x='time', y=['speed_kilometers_per_hour', | |
'distance_total_geodesic_kilometers', | |
'altitude'], | |
template='plotly_dark') | |
fig_2.show() |
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
# ---------------------------- | |
# Get the results | |
# key points of the session | |
print('SessionStart: ' + str(gpx_df.iloc[0,0])) | |
print('SessionStop: ' + str(gpx_df.iloc[-1,0])) | |
print('SessionDuration (hh:mm:ss): ' + str(gpx_df['time'].max() - gpx_df['time'].min())) | |
print('SessionDistanceTotal: ' + str(round((gpx_df['distance_delta_geodesic_meters'].sum() | |
/1000), 3)) + ' km') | |
print('SessionWayUp: ' + str(altitude_total_up) + ' m') |
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 sums | |
# calculate Total altitude_total_up, altitude_total_down | |
altitude_total_up = 0 | |
altitude_total_down = 0 | |
for i in gpx_df['altitude_delta_meters']: | |
if i > 0.0: | |
altitude_total_up += i |
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
print(gpx_df.info()) |
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 delta | |
# time_delta | |
## calculate and add column time_delta | |
gpx_df['time_delta'] = gpx_df['time'].shift(-1)-gpx_df['time'] | |
## translate the time_delta in seconds | |
gpx_df['time_delta_seconds'] = ((gpx_df['time_delta']. | |
fillna(pd.Timedelta(seconds=0)). | |
view('int64')/1000000000)) |
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
print(gpx_df.head(5)) |
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
print(gpx_df.info()) |
NewerOlder