Python on the Web. Showcasing Python applications on the… | by Pier Paolo Ippolito | Oct, 2023


Using popular Python visualization libraries it can be relatively straightforward to create locally charts and dashboards of different forms. Although, it can be much more complicated to share your results with other people on the web.

One possible approach to do this is using libraries such as Streamlit, Flask, Plotly Dash and paying for a web hosting service to cover the server side and run your Python scripts to show on the webpage. Alternatively, some providers like Plotly Chart or Datapane provide also free cloud support for you to upload your Python visualizations and then embed them on the web. In both scenarios, you would be able to achieve anything you need if you have a small budget for your project, but there is any way we could achieve similar results for free?

As part of this article, we are going to explore 3 possible approaches:

In order to showcase each of these 3 approaches, we are going to create a simple application to explore historical inflation data from all over the world. In order to do so, we are going to use The World Bank Gloabal Database of Inflation all information about licensing for the data can be found at this link [1].

Once downloaded the data, we can then use the following pre-processing function in order to better shape the dataset for visualization and import just the 3 Excel Sheets we are going to use as part of the analysis (overall inflation data, inflation for food and energy prices).

import pandas as pd

def import_data(name):
df = pd.read_excel("Inflation-data.xlsx", sheet_name=name)
df = df.drop(["Country Code", "IMF Country Code", "Indicator Type", "Series Name", "Unnamed: 58"], axis=1)
df = (df.melt(id_vars = ['Country', 'Note'],
var_name = 'Date', value_name = 'Inflation'))
df = df.pivot_table(index='Date', columns='Country',
values='Inflation', aggfunc='sum')
return df

inf_df = import_data("hcpi_a")
food_df = import_data("fcpi_a")
energy_df = import_data("ecpi_a")



Source link

This post originally appeared on TechToday.

Leave a Reply

Your email address will not be published. Required fields are marked *