Update app.py
Browse files
app.py
CHANGED
|
@@ -33,14 +33,14 @@ hv.extension('bokeh')
|
|
| 33 |
def create_plot(selectedcol,selecteditem,todaydate,selectedmethod):
|
| 34 |
df = get_df(todaydate)
|
| 35 |
if selectedmethod=='Mean':
|
| 36 |
-
|
| 37 |
if selectedmethod=='Min':
|
| 38 |
-
|
| 39 |
if selectedmethod=='Max':
|
| 40 |
-
|
| 41 |
-
df2 = df.merge(
|
| 42 |
|
| 43 |
-
return df2.hvplot.bar(x=selecteditem, y=f'{selectedcol}_{selecteditem}
|
| 44 |
|
| 45 |
bound_plot = pn.bind(create_plot, selectedcol=selectedcol , selecteditem=selecteditem, todaydate=todaydate, selectedmethod=selectedmethod)
|
| 46 |
pn.Column(pn.Row(selectedcol, selecteditem, todaydate,selectedmethod), bound_plot).servable(title="Financial Sector Ratios Navigator")
|
|
|
|
| 33 |
def create_plot(selectedcol,selecteditem,todaydate,selectedmethod):
|
| 34 |
df = get_df(todaydate)
|
| 35 |
if selectedmethod=='Mean':
|
| 36 |
+
group_them = df.groupby(selecteditem)[selectedcol].mean()
|
| 37 |
if selectedmethod=='Min':
|
| 38 |
+
group_them = df.groupby(selecteditem)[selectedcol].min()
|
| 39 |
if selectedmethod=='Max':
|
| 40 |
+
group_them = df.groupby(selecteditem)[selectedcol].max()
|
| 41 |
+
df2 = df.merge(group_them, left_on=selecteditem, right_index=True, suffixes=('', f'_{selecteditem}_{selectedmethod}'))
|
| 42 |
|
| 43 |
+
return df2.hvplot.bar(x=selecteditem, y=f'{selectedcol}_{selecteditem}_{selectedmethod}', hover_cols=selectedhover, height=800, width=1800).opts(xrotation=90, fontsize={'xticks': 10})
|
| 44 |
|
| 45 |
bound_plot = pn.bind(create_plot, selectedcol=selectedcol , selecteditem=selecteditem, todaydate=todaydate, selectedmethod=selectedmethod)
|
| 46 |
pn.Column(pn.Row(selectedcol, selecteditem, todaydate,selectedmethod), bound_plot).servable(title="Financial Sector Ratios Navigator")
|