import streamlit as st
from great_tables import GT, html
from great_tables.data import sza
# @st.cache_data
def get_sza_pivot():
return (
sza.assign(tst_int=lambda df_: df_.tst.astype(int))
.query("latitude == '20' and tst_int <= 1200")
.drop(["latitude", "tst_int"], axis=1)
.dropna()
.pivot(values=["sza"], index=["month"], columns=["tst"])
.droplevel(0, axis=1)
.reindex(
[
"jan",
"feb",
"mar",
"apr",
"may",
"jun",
"jul",
"aug",
"sep",
"oct",
"nov",
"dec",
],
axis=0,
)
.reset_index(names="month")
)
def get_sza_gt():
return (
GT(get_sza_pivot(), rowname_col="month")
.data_color(
domain=[90, 0],
palette=[color1, "white", color2],
na_color="white",
)
.tab_header(
title="Solar Zenith Angles from 05:30 to 12:00",
subtitle=html("Average monthly values at latitude of 20°N."),
)
.sub_missing(missing_text="")
)
st.title("Great Tables shown in Streamlit")
_, col1, _, col2, _ = st.columns([1, 1, 1, 1, 1])
with col1:
color1 = st.color_picker("Color 1", "#C0DA80")
with col2:
color2 = st.color_picker("Color 2", "#FFD580")
st.write(get_sza_gt().as_raw_html(), unsafe_allow_html=True)