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

Fix Pandas 0.24 DateOffset bug pt. 2 #7981

Merged
merged 2 commits into from
Aug 7, 2019
Merged

Fix Pandas 0.24 DateOffset bug pt. 2 #7981

merged 2 commits into from
Aug 7, 2019

Conversation

villebro
Copy link
Member

@villebro villebro commented Aug 3, 2019

CATEGORY

Choose one

  • Bug Fix

SUMMARY

This should fix the DateOffset bug that was introduced when moving from Pandas 0.23 to 0.24. Credits for this go to @jbrockmendel, see pandas-dev/pandas#27728

TEST PLAN

Tested locally

ADDITIONAL INFORMATION

REVIEWERS

@betodealmeida @AndLLA

@AndLLA
Copy link

AndLLA commented Aug 4, 2019

The patch works for my use case (time grain=day, frequency 1week)
Thanks !!!!

I tried an alternative configuration (freq = 4weeks), but the chart is still the same as for 1week.

I also tried "frequency = day", but I get an error (but maybe I'm miss-using the chart): Tick offset with normalize=True are not allowed.

Traceback (most recent call last):
  File "/home/superset/venvSS/lib/python3.6/site-packages/superset/views/base.py", line 122, in wraps
    return f(self, *args, **kwargs)
  File "/home/superset/venvSS/lib/python3.6/site-packages/superset/utils/decorators.py", line 70, in wrapper
    return f(*args, **kwargs)
  File "/home/superset/venvSS/lib/python3.6/site-packages/superset/views/core.py", line 1097, in explore_json
    viz_obj, csv=csv, query=query, results=results, samples=samples
  File "/home/superset/venvSS/lib/python3.6/site-packages/superset/views/core.py", line 1018, in generate_json
    payload = viz_obj.get_payload()
  File "/home/superset/venvSS/lib/python3.6/site-packages/superset/viz.py", line 379, in get_payload
    payload["data"] = self.get_data(df)
  File "/home/superset/venvSS/lib/python3.6/site-packages/superset/viz.py", line 1401, in get_data
    freq = type(freq)(freq.n, normalize=True, **freq.kwds)
  File "/home/superset/venvSS/lib/python3.6/site-packages/pandas/tseries/offsets.py", line 2247, in __init__
    raise ValueError("Tick offset with `normalize=True` are not "
ValueError: Tick offset with `normalize=True` are not allowed.

@villebro
Copy link
Member Author

villebro commented Aug 4, 2019

Thanks for testing @AndLLA ! Let's get that last error sorted, I think we're pretty close.

@villebro
Copy link
Member Author

villebro commented Aug 4, 2019

Can you do another round of testing @AndLLA ? Seems to work for me.

@jbrockmendel
Copy link

FYI the Tick offsets (Day, Hour, Minute, ...) had normalize disallowed because they caused unexpected arithmetic behavior.

More generally, the immutability was put in place because it led to major performance improvements when working with PeriodIndex/Array.

@AndLLA
Copy link

AndLLA commented Aug 5, 2019

It works also for me :)
Thanks !!!!!

@codecov-io
Copy link

Codecov Report

Merging #7981 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7981      +/-   ##
==========================================
- Coverage   65.58%   65.57%   -0.02%     
==========================================
  Files         469      469              
  Lines       22407    22409       +2     
  Branches     2432     2432              
==========================================
- Hits        14695    14694       -1     
- Misses       7591     7594       +3     
  Partials      121      121
Impacted Files Coverage Δ
superset/viz.py 71.59% <0%> (-0.16%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b856666...0b42137. Read the comment docs.

@betodealmeida
Copy link
Member

LGTM, but we should address the underlying problem at some point.

@betodealmeida betodealmeida merged commit 8cd8ec1 into apache:master Aug 7, 2019
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time-series Period Pivot - DateOffset objects are immutable
6 participants