From 7f13d0823b35af54dbe4ac8bd81702a2c855601b Mon Sep 17 00:00:00 2001 From: Karen Zeng Date: Wed, 17 May 2023 15:01:04 -0400 Subject: [PATCH] Used plotly to generate a graph --- View_h5_file.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/View_h5_file.py b/View_h5_file.py index a460766..da8d19e 100644 --- a/View_h5_file.py +++ b/View_h5_file.py @@ -1,5 +1,7 @@ import h5py import pandas as pd +import numpy as np +import plotly.graph_objects as go f = h5py.File('product1.h5','r') list(f.keys()) @@ -9,3 +11,15 @@ for key in f.keys(): # print(f[key].value) df = pd.read_hdf('product1.h5', key='df8') print(df) + +# Calculate the standard deviation using pandas' function +std_dev_unit = df.groupby('Zip Code')['Unit Price'].std() +std_dev_displayed = df.groupby('Zip Code')['Shown Price'].std() + +# Generate the graph using Plotly +fig = go.Figure() +fig.add_trace(go.Bar(x=std_dev_unit.index, y=std_dev_unit.values)) +fig.update_layout(title='Standard Deviation of the Unit Pricing by Item', xaxis_title='Zip Code', yaxis_title='Standard Deviation') + +report_file = 'test.html' +fig.write_html(report_file)