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

too many log messages #46

Closed
JeromeSchmied opened this issue Sep 25, 2024 · 5 comments · Fixed by #49
Closed

too many log messages #46

JeromeSchmied opened this issue Sep 25, 2024 · 5 comments · Fixed by #49
Labels
bug Something isn't working

Comments

@JeromeSchmied
Copy link

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
Copy link
Collaborator

hugovk commented Sep 30, 2024

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 hugovk added the bug Something isn't working label Sep 30, 2024
@hugovk
Copy link
Collaborator

hugovk commented Oct 2, 2024

Please see #49.

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

@JeromeSchmied
Copy link
Author

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
Copy link
Collaborator

hugovk commented Oct 2, 2024

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
Copy link
Author

wonderful, works like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants