Comparing current period with previous period

Hi, I am new to Streamlit and was hoping this community could provide some guidance please.

I was wondering if it is possible to compare aggregated data for a time period with the previous period using streamlit/pandas?

For example, I might have three columns - date, region and sales.

Then I would like the ability to select a date range and view a table with the following columns…

region, total sales, change

The change column would be the percentage change of the current period compared to the previous period. Some sort of colour (green or red) indicator would also be helpful to indicate a positive/negative change.

Google Data Studio has this built in and I would like to replicate it.

Please see the example below from Google Data Studio. The %change column is the one I am trying to replicate.

gds_compare_periods.jpeg

Thank you.

Hi @ad888,

Thanks for posting!

If you can share what you’ve written so far, we can help point you in the right direction.

Some helpful resources:

Caroline :balloon: