Fix for new Pandas API (#7975)

This commit is contained in:
Beto Dealmeida 2019-08-02 15:28:39 -07:00 committed by GitHub
parent e23920b8ba
commit b8ca0783ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -42,6 +42,7 @@ from markdown import markdown
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
@ -1398,7 +1399,8 @@ class NVD3TimePivotViz(NVD3TimeSeriesViz):
fd = self.form_data
df = self.process_data(df)
freq = to_offset(fd.get("freq"))
freq.normalize = True
freq = DateOffset(normalize=True, **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
df.ranked = df.ranked.map(int)