superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject [incubator-superset] branch master updated: Fix Pandas 0.24 DateOffset bug pt. 2 (#7981)
Date Wed, 07 Aug 2019 21:17:37 GMT
This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 8cd8ec1  Fix Pandas 0.24 DateOffset bug pt. 2 (#7981)
8cd8ec1 is described below

commit 8cd8ec16d5017076b639a76514069cc276f930ad
Author: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
AuthorDate: Thu Aug 8 00:17:23 2019 +0300

    Fix Pandas 0.24 DateOffset bug pt. 2 (#7981)
    
    * Fix pandas 0.24 DateOffset bug
    
    * Add try-catch for DateOffsets that don't support normalize
---
 superset/viz.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/superset/viz.py b/superset/viz.py
index d6d0259..abd908c 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -42,7 +42,6 @@ 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
 
@@ -1402,7 +1401,10 @@ class NVD3TimePivotViz(NVD3TimeSeriesViz):
         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


Mime
View raw message