This also revealed a problem with Pandas 2 in stravavis:
❯ stravavis tests/gpx --activities_path tests/csv
...
Plotting dumbbell...
/Users/hugo/github/strava_py/src/stravavis/plot_dumbbell.py:43: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
/Users/hugo/github/strava_py/src/stravavis/plot_dumbbell.py:46: PerformanceWarning: Adding/subtracting object-dtype array to DatetimeArray not vectorized.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/bin/stravavis", line 8, in <module>
sys.exit(main())
^^^^^^
File "/Users/hugo/github/strava_py/src/stravavis/cli.py", line 142, in main
plot_dumbbell(activities, output_file=outfile)
File "/Users/hugo/github/strava_py/src/stravavis/plot_dumbbell.py", line 60, in plot_dumbbell
activities["end_time"] = activities["end"].dt.time
^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pandas/core/generic.py", line 5989, in __getattr__
return object.__getattribute__(self, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pandas/core/accessor.py", line 224, in __get__
accessor_obj = self._accessor(obj)
^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pandas/core/indexes/accessors.py", line 580, in __new__
raise AttributeError("Can only use .dt accessor with datetimelike values")
AttributeError: Can only use .dt accessor with datetimelike values. Did you mean: 'at'?
Follow on from https://github.com/marcusvolz/strava_py/pull/32.
https://pypi.org/project/calmap/0.0.11/ has been released and now supports Pandas 2, so we can remove the
pandas<2
limit.This also revealed a problem with Pandas 2 in stravavis:
It's this line:
Printing those with Pandas 1.5.3:
Gives:
So: datetime64[ns] + object = datetime64[ns], that's fine.
But with Pandas 2.0.3:
datetime64[ns] + object = object
Instead, let's make sure the end time is a datetime:
This works with both Pandas < 2 and >=2.