Used plotly to generate a graph

This commit is contained in:
2023-05-17 15:01:04 -04:00
parent 0e909fc3f9
commit 7f13d0823b
+14
View File
@@ -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)