graph_generator module#
Generate Graph for cycling power.
This module provides the necessary functions to generate graphical views of a strava user’s power over time.
- graph_generator.activity_zone(connection, activity_data_frame)#
Heart rate zone of activity
If a user is a premium member, add the zone of their activities to their activity dataframe. This is determined by finding the max time spent in each heart rate zone for an activity defined by its id.
- Parameters:
connection (object) – an instance of urllib3 Pool Manager
activity_data_frame (dataframe) – dataframe containing id, date, avg watts, max watts
- Returns:
returns an updated dataframe with zone data
- Return type:
dataframe
- graph_generator.connect_to_strava()#
Connect to strava API
Connect to Strava API by creating an instance of urllib3 pool manager.
- Parameters:
None –
- Returns:
An instance of urllib3 Pool Manager
- Return type:
object
- graph_generator.dict_to_df(dictionary)#
Dictionary to dataframe conversion kit.
Converts a dictionary of authorized user’s activities to a dataframe
- Parameters:
dictionary (dict) – dictionary containing list of activities
- Returns:
dataframe containing all activities
- Return type:
dataframe
Is strava user a premium subscriber
Determines if a strava user is a premium subscriber. This is to determine if I can access their zone data through the API.
- Parameters:
connection (object) – an instance of urllib3 Pool Manager
- Returns:
- returns boolean value for if the user is a strava
premium member
- Return type:
boolean
- graph_generator.json_to_dict(activity_data)#
json to dictionary conversion kit.
Converts list of acitvities in json form to a Python dictionary.
- Parameters:
activity_data (json) – a json containing list of activities
- Returns:
dictionary containing list of activities
- Return type:
dictionary
- graph_generator.strava_data_for_graph()#
Gather data for graphical view
Retreives a list of authorized users’ activities, and converts json containing activities into a dataframe.
- Parameters:
None –
- Returns:
dataframe containing all activities
- Return type:
dataframe