Skip to content

Commit

Permalink
Implement rolling api introduced in pandas 0.18 (#5328)
Browse files Browse the repository at this point in the history
* Implement new rolling api introduced in pandas 0.18

* Bump pandas to 0.23.1

* Add 0.18 requirement in setup.py

* Require >=0.18.0, not just 0.18
  • Loading branch information
villebro authored and mistercrunch committed Jul 4, 2018
1 parent 059b64d commit 6fee058
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ gunicorn==19.8.0
humanize==0.5.1
idna==2.6
markdown==2.6.11
pandas==0.22.0
pandas==0.23.1
parsedatetime==2.0.0
pathlib2==2.3.0
polyline==1.3.2
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_git_sha():
'humanize',
'idna',
'markdown',
'pandas',
'pandas>=0.18.0',
'parsedatetime',
'pathlib2',
'polyline',
Expand Down
7 changes: 3 additions & 4 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,15 +1175,14 @@ def process_data(self, df, aggregate=False):

if rolling_type in ('mean', 'std', 'sum') and rolling_periods:
kwargs = dict(
arg=df,
window=rolling_periods,
min_periods=min_periods)
if rolling_type == 'mean':
df = pd.rolling_mean(**kwargs)
df = df.rolling(**kwargs).mean()
elif rolling_type == 'std':
df = pd.rolling_std(**kwargs)
df = df.rolling(**kwargs).std()
elif rolling_type == 'sum':
df = pd.rolling_sum(**kwargs)
df = df.rolling(**kwargs).sum()
elif rolling_type == 'cumsum':
df = df.cumsum()
if min_periods:
Expand Down

0 comments on commit 6fee058

Please sign in to comment.