Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare activities.csv's date format to prevent Pandas getting confused if the first was in May #32

Merged
merged 2 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Test run
run: |
stravavis --help
stravavis tests/gpx
stravavis tests/gpx --activities_path tests/csv

- name: Upload output images
uses: actions/upload-artifact@v3
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ install_requires =
fit2gpx
gpxpy
matplotlib
pandas
# Pending https://github.com/MarvinT/calmap/pull/14
pandas<2
plotnine
rich
seaborn
Expand Down
7 changes: 6 additions & 1 deletion src/stravavis/plot_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
import matplotlib.pyplot as plt
import pandas as pd


ACTIVITY_FORMAT = "%b %d, %Y, %H:%M:%S %p"

def plot_calendar(activities, year_min=None, year_max=None, max_dist=None,
fig_height = 15, fig_width = 9, output_file='calendar.png'):
# Create a new figure
plt.figure()

# Process data
activities['Activity Date'] = pd.to_datetime(activities['Activity Date'])
activities["Activity Date"] = pd.to_datetime(
activities["Activity Date"], format=ACTIVITY_FORMAT
)
activities['date'] = activities['Activity Date'].dt.date
activities = activities.groupby(['date'])['Distance'].sum()
activities.index = pd.to_datetime(activities.index)
Expand Down
9 changes: 9 additions & 0 deletions tests/csv/activities.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Activity ID,Activity Date,Activity Name,Activity Type,Activity Description,Elapsed Time,Distance,Max Heart Rate,Relative Effort,Commute,Activity Private Note,Activity Gear,Filename,Athlete Weight,Bike Weight,Elapsed Time,Moving Time,Distance,Max Speed,Average Speed,Elevation Gain,Elevation Loss,Elevation Low,Elevation High,Max Grade,Average Grade,Average Positive Grade,Average Negative Grade,Max Cadence,Average Cadence,Max Heart Rate,Average Heart Rate,Max Watts,Average Watts,Calories,Max Temperature,Average Temperature,Relative Effort,Total Work,Number of Runs,Uphill Time,Downhill Time,Other Time,Perceived Exertion,"<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.type"">Type</span>","<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.start_time"">Start Time</span>",Weighted Average Power,Power Count,Prefer Perceived Exertion,Perceived Relative Effort,Commute,Total Weight Lifted,From Upload,Grade Adjusted Distance,Weather Observation Time,Weather Condition,Weather Temperature,Apparent Temperature,Dewpoint,Humidity,Weather Pressure,Wind Speed,Wind Gust,Wind Bearing,Precipitation Intensity,Sunrise Time,Sunset Time,Moon Phase,Bike,Gear,Precipitation Probability,Precipitation Type,Cloud Cover,Weather Visibility,UV Index,Weather Ozone,"<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.jump_count"">Jump Count</span>","<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.total_grit"">Total Grit</span>","<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.avg_flow"">Avg Flow</span>","<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.flagged"">Flagged</span>","<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.avg_elapsed_speed"">Avg Elapsed Speed</span>","<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.dirt_distance"">Dirt Distance</span>","<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.newly_explored_distance"">Newly Explored Distance</span>","<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.newly_explored_dirt_distance"">Newly Explored Dirt Distance</span>","<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.sport_type"">Sport Type</span>","<span class=""translation_missing"" title=""translation missing: en-US.lib.export.portability_exporter.activities.horton_values.total_steps"">Total Steps</span>",Media
9125662739,"May 23, 2023, 12:40:57 PM",Evening Ride,Ride,,6124,33.91,,,false,,TCR ADV 3,,,,6124,5103,33912.48046875,28.0181102752686,6.64559698104858,124,126,-20,58,44.4619865417481,0.002948766807094,,,,0,,0,,87.1724853515625,683,,21,,,,,,,6,,,,,0,134,0,,1,,,,,,,,,,,,,,,,12622314,,,,,,,,,,,0,5.53763580322266,1318.80004882813,,,,,
9148958024,"May 27, 2023, 1:24:16 AM",Morning Ride,Ride,,31872,122.67,,,false,,TCR ADV 3,,,,31872,19143,122675.9921875,12.3882808685303,6.40839958190918,373,357,-7,108,46.9055366516113,0.005706088151783,,,,0,,0,,117.04443359375,2562,,33,,,,,,,8,,,,,0,824,0,,1,,,,,,,,,,,,,,,,12622314,,,,,,,,,,,0,3.84902095794678,0,,,,,
9189096048,"Jun 2, 2023, 11:48:52 AM",Evening Ride,Ride,,14194,51.83,,,false,,TCR ADV 3,,,,14194,8405,51837.44921875,12.9382810592651,6.16745376586914,393,399,10,190,49.4113121032715,0.023149287328124,,,,0,,0,,126.669448852539,1079,,26,,,,,,,9,,,,,0,420,0,,1,,,,,,,,,,,,,,,,12622314,,,,,,,,,,,0,3.6520676612854,0,,,,,
9233077380,"Jun 9, 2023, 1:02:03 PM",Night Ride,Ride,,5280,32.84,,,false,,TCR ADV 3,,,,5280,4862,32848.51171875,10.8902339935303,6.75617265701294,132,134,12,79,36.616626739502,0.015221389941871,,,,0,,0,,129.770172119141,649,,29,,,,,,,7,,,,,0,155,0,,1,,,,,,,,,,,,,,,,12622314,,,,,,,,,,,0,6.22130918502808,0,,,,,
9233439372,"Jun 9, 2023, 1:02:03 PM",Evening Ride,Ride,,5280,32.84,,,false,,TCR ADV 3,,,8,5280,4862,32848.51171875,10.8902339935303,6.75617265701294,132,134,12,79,36.616626739502,0.015221389941871,,,,0,,0,,129.728652954102,649,,29,,,,,,,,,,,,,,0,,1,,,,,,,,,,,,,,,,12622314,,,,,,,,,,,0,6.22130918502808,0,,,,,
9239384321,"Jun 10, 2023, 10:36:58 AM",Evening Ride,Ride,,14142,67.2,,,false,,TCR ADV 3,,,8,14142,10121,67206.78125,10.5140628814697,6.64033031463623,219,238,-20,60,48.9795913696289,-0.002975890180096,,,,0,,0,,121.037376403809,1350,,31,,,,,,,8,,,,,0,435,0,,1,,,,,,,,,,,,,,,,12622314,,,,,,,,,,,0,4.75228261947632,0,,,,,
9251030970,"May 20, 2023, 1:30:00 AM",Morning Ride,Ride,,14599,88.21,,,false,,TCR ADV 3,,,8,14599,14599,88210,,6.04219484329224,160,,,,,0,,,,,,,,,,,,,,,,,,8,,,,,0,628,0,,0,,,,,,,,,,,,,,,,12622314,,,,,,,,,,,0,6.04219484329224,0,,,,,
9251043755,"May 13, 2023, 12:38:00 AM",Morning Ride,Ride,,16303,67.16,,,false,,TCR ADV 3,,,8,16303,16303,67160,,4.11948728561401,366,,,,,0,,,,,,,,,,,,,,,,,,9,,,,,0,815,0,,0,,,,,,,,,,,,,,,,12622314,,,,,,,,,,,0,4.11948728561401,0,,,,,