Showing results for 
Search instead for 
Did you mean: 
Community Team Member
Community Team Member
Want to show a rolling average to your data? Using the Sisense for Cloud Data Teams Python / R integration, we can accomplish this with a single line of Python code.

Here are the first few rows of our SQL output - a list of dates with the number of users created on a fictional gaming platform.
We now use the rolling() function from Python pandas, as shown below.  Note that by changing the .mean() to a .sum(), we can now make this a rolling sum calculation. Neat, huh? 
# SQL output is imported as a pandas dataframe variable called "df"
import pandas as pd

df["rolling"] = df["number_users"].rolling(10).mean()

# Use Sisense for Cloud Data Teams to visualize a dataframe or an image by passing data to periscope.output()
Now, we make this chart a line graph to visualize the rolling average line by itself!
Tip: If you want to display both the raw data and the rolling average, Sisense for Cloud Data Teams' built-in visualizations has a quick "Show Rolling Average" check box that you can toggle on. 
Want to stick to SQL? You can run the same calculation using SQL window functions as shown here
Prefer R? 

Find the R equivalent for this post here
Version history
Last update:
‎03-02-2023 09:32 AM
Updated by:
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?