Files

26 lines
766 B
Python
Raw Permalink Normal View History

2023-05-16 16:44:15 -04:00
import h5py
import pandas as pd
2023-05-17 15:01:04 -04:00
import numpy as np
import plotly.graph_objects as go
2023-05-16 16:44:15 -04:00
f = h5py.File('product1.h5','r')
list(f.keys())
for key in f.keys():
print(f[key])
# print(f[key].shape)
# print(f[key].value)
df = pd.read_hdf('product1.h5', key='df8')
print(df)
2023-05-17 15:01:04 -04:00
# 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)