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
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
6 changes: 4 additions & 2 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import numpy as np
import pandas as pd
from pandas.tseries.frequencies import to_offset
from pandas.tseries.offsets import DateOffset
import polyline
import simplejson as json

Expand Down Expand Up @@ -1399,7 +1398,10 @@ def get_data(self, df):
fd = self.form_data
df = self.process_data(df)
freq = to_offset(fd.get("freq"))
freq = DateOffset(normalize=True, **freq.kwds)
try:
freq = type(freq)(freq.n, normalize=True, **freq.kwds)
except ValueError:
freq = type(freq)(freq.n, **freq.kwds)
df.index.name = None
df[DTTM_ALIAS] = df.index.map(freq.rollback)
df["ranked"] = df[DTTM_ALIAS].rank(method="dense", ascending=False) - 1
Expand Down