marcusvolz / strava_py

Create artistic visualisations with your exercise data (Python version)
MIT License
168 stars 19 forks source link

too many log messages #46

Closed JeromeSchmied closed 1 month ago

JeromeSchmied commented 1 month ago

I guess, pandas is pretty angry, as it sends me a message like this extremely often.

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
/home/jero/code/python/strava_vis/.venv/lib/python3.12/site-packages/stravavis/plot_landscape.py:23: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
hugovk commented 1 month ago

There's quite a few warnings, I agree they're distracting.

Would you like to have a go and fix some of them?

❯ stravavis tests/gpx --activities_path tests/csv
Processing data...
Cache filename: /var/folders/p6/lf2s1s5d4kb335g2n1td8z8c0000gn/T/stravavis/cached_activities_b433cb7c8d630085d380e6b3e58fd4c0.pkl
Cache not found
Processing ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:--
Skipping tests/gpx/invalid-lon-lat-missing.gpx: GPXException: latitude is mandatory in None (got None)
Processing ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Processing activities...
Plotting facets...
Saved to strava-facets.png
Plotting map...
Plotting activities ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Saved to strava-map.png
Plotting elevations...
Saved to strava-elevations.png
Plotting landscape...
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/stravavis/plot_landscape.py:23: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/stravavis/plot_landscape.py:23: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/stravavis/plot_landscape.py:23: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
Processing tracks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Plotting activities ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Saved to strava-landscape.png
Plotting calendar...
Saved to strava-calendar.png
Plotting dumbbell...
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/stravavis/plot_dumbbell.py:45: FutureWarning: ChainedAssignmentError: behaviour will change in pandas 3.0!
You are setting values through chained assignment. Currently this works in certain cases, but when using Copy-on-Write (which will become the default behaviour in pandas 3.0) this will never work to update the original DataFrame or Series, because the intermediate object on which we are setting values will behave as a copy.
A typical example is when you are setting values in a column of a DataFrame, like:

df["col"][row_indexer] = value

Use `df.loc[row_indexer, "col"] = values` instead, to perform the assignment in a single step and ensure this keeps updating the original `df`.

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/stravavis/plot_dumbbell.py:45: 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
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/stravavis/plot_dumbbell.py:45: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value '0 days 01:42:04' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/stravavis/plot_dumbbell.py:48: PerformanceWarning: Adding/subtracting object-dtype array to DatetimeArray not vectorized.
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/plotnine/ggplot.py:587: PlotnineWarning: Saving 34.0 x 34.0 cm image.
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/plotnine/ggplot.py:588: PlotnineWarning: Filename: strava-dumbbell.png
Saved to strava-dumbbell.png
hugovk commented 1 month ago

Please see https://github.com/marcusvolz/strava_py/pull/49.

python3 -m pip install git+https://github.com/hugovk/strava_py.git@fix-pandas-warnings
JeromeSchmied commented 1 month ago

well, I'm not quite sure what's going on, might be uv's problem, but it says

> uv pip install git+https://github.com/hugovk/strava_py.git@fix-pandas-warnings
Updating https://github.com/hugovk/strava_py.git (fix-pandas-warnings)                                                                                          error: Git operation failed
  Caused by: failed to fetch into: /home/jero/.cache/uv/git-v0/db/8c5a98dd571d6bba
  Caused by: failed to fetch branch or tag `fix-pandas-warnings`
  Caused by: process didn't exit successfully: `git fetch --force --update-head-ok 'https://github.com/hugovk/strava_py.git' '+refs/tags/fix-pandas-warnings:refs/remotes/origin/tags/fix-pandas-warnings'` (exit status: 128)
--- stderr
fatal: couldn't find remote ref refs/tags/fix-pandas-warnings
hugovk commented 1 month ago

Sorry, my mistake, got the wrong branch name. Try:

python3 -m pip install git+https://github.com/hugovk/strava_py.git@fix-warnings

Cool to see the use of uv :)

JeromeSchmied commented 1 month ago

wonderful, works like a charm