Spaces:
Runtime error
Runtime error
import streamlit as st | |
from utils import get_calculated_df, get_info, text2oddslist | |
amount: int = int(st.number_input("amount", min_value=100, value=3000, step=100)) | |
text: str = st.text_area("text", "") | |
# ボタンを作る | |
st.button("calculate") | |
if text: | |
df = get_calculated_df(amount, text2oddslist(text)) | |
# dataframeを綺麗に出力する | |
info = get_info(df) | |
col1, col2 = st.columns(2) | |
with col1: | |
st.markdown(f"#### 購入額: ¥ **{info['sum']:,}**") | |
st.markdown(f"#### 点 数: **{info['num_kind']}** 点") | |
with col2: | |
st.metric( | |
label="払戻", | |
value=f"¥ {info['refound_mean']:,}", | |
delta=f"{info['profit_mean']:+,}({info['rate_min']:.0%})", | |
) | |
st.markdown("---") | |
# dfの表示 | |
display_cols = ["odds", "buy", "refound"] | |
if df["name"].map(lambda name: name != "").any(): | |
display_cols = ["name"] + display_cols | |
st.dataframe(df[display_cols]) | |