Spaces:
Sleeping
Sleeping
tappyness1 commited on
Commit ·
abb5fd4
1
Parent(s): 537f041
update for later streamlit version
Browse files
app.py
CHANGED
|
@@ -22,14 +22,14 @@ age_bounty_fp = pl_config['SCRAPER'].get('age_bounty_fp')
|
|
| 22 |
|
| 23 |
st.set_page_config(page_title='One Dash', layout = 'wide', initial_sidebar_state = 'auto')
|
| 24 |
|
| 25 |
-
@st.cache_data(
|
| 26 |
def generate_df():
|
| 27 |
appearance_df = pd.read_csv(chap_appearance_fp)
|
| 28 |
char_details_df = pd.read_csv(char_details_fp)
|
| 29 |
df_age_bounty = pd.read_csv(age_bounty_fp)
|
| 30 |
return appearance_df, char_details_df, df_age_bounty
|
| 31 |
|
| 32 |
-
@st.cache_data(
|
| 33 |
def fig_app_by_arc(appearance_df, height):
|
| 34 |
fig_app_by_arc = px.histogram(appearance_df[appearance_df['Appearance'].isin(appearance_df['Appearance'].value_counts().head(20).index.tolist())],
|
| 35 |
x='Appearance',
|
|
@@ -48,7 +48,7 @@ def fig_app_by_arc(appearance_df, height):
|
|
| 48 |
)
|
| 49 |
return fig_app_by_arc
|
| 50 |
|
| 51 |
-
@st.cache_data(
|
| 52 |
def fig_app_by_arc_sunburst(appearance_df):
|
| 53 |
fig_app_by_arc_sunburst = px.sunburst(appearance_df[appearance_df['Appearance'].isin(appearance_df['Appearance'].value_counts().head(10).index.tolist())],
|
| 54 |
path = ['Appearance', 'Arc'],
|
|
@@ -56,7 +56,7 @@ def fig_app_by_arc_sunburst(appearance_df):
|
|
| 56 |
height = 800)
|
| 57 |
return fig_app_by_arc_sunburst
|
| 58 |
|
| 59 |
-
@st.cache_data(
|
| 60 |
def fig_latest_bounty(char_details_df, height):
|
| 61 |
df = char_details_df[char_details_df['last_bounty'] > 0]
|
| 62 |
df = df.sort_values(by = "last_bounty", ascending = False)
|
|
@@ -73,7 +73,7 @@ def fig_latest_bounty(char_details_df, height):
|
|
| 73 |
)
|
| 74 |
return fig_latest_bounty
|
| 75 |
|
| 76 |
-
@st.cache_data(
|
| 77 |
def fig_latest_bounty_dist(char_details_df, height):
|
| 78 |
group_df = char_details_df[['main_crew','last_bounty']]
|
| 79 |
group_df = group_df.groupby(['main_crew']).sum()
|
|
@@ -88,7 +88,7 @@ def fig_latest_bounty_dist(char_details_df, height):
|
|
| 88 |
)
|
| 89 |
return fig_latest_bounty_dist
|
| 90 |
|
| 91 |
-
@st.cache_data(
|
| 92 |
def fig_latest_age_to_bounty(df_age_bounty,height):
|
| 93 |
fig_latest_age_to_bounty = px.scatter(x = df_age_bounty['latest_age'],
|
| 94 |
y=df_age_bounty['last_bounty'],
|
|
@@ -106,7 +106,7 @@ def fig_latest_age_to_bounty(df_age_bounty,height):
|
|
| 106 |
)
|
| 107 |
return fig_latest_age_to_bounty
|
| 108 |
|
| 109 |
-
@st.cache_data(
|
| 110 |
def fig_age_to_bounty_by_crew(df_age_bounty, height):
|
| 111 |
fig_age_to_bounty_by_crew = px.scatter(x = df_age_bounty['latest_age'],
|
| 112 |
y=df_age_bounty['last_bounty'],
|
|
@@ -124,7 +124,6 @@ def fig_age_to_bounty_by_crew(df_age_bounty, height):
|
|
| 124 |
)
|
| 125 |
return fig_age_to_bounty_by_crew
|
| 126 |
|
| 127 |
-
# @st.cache(suppress_st_warning=True, persist = True)
|
| 128 |
def main():
|
| 129 |
appearance_df, char_details_df, df_age_bounty = generate_df()
|
| 130 |
# st.set_page_config(layout="wide")
|
|
|
|
| 22 |
|
| 23 |
st.set_page_config(page_title='One Dash', layout = 'wide', initial_sidebar_state = 'auto')
|
| 24 |
|
| 25 |
+
@st.cache_data()
|
| 26 |
def generate_df():
|
| 27 |
appearance_df = pd.read_csv(chap_appearance_fp)
|
| 28 |
char_details_df = pd.read_csv(char_details_fp)
|
| 29 |
df_age_bounty = pd.read_csv(age_bounty_fp)
|
| 30 |
return appearance_df, char_details_df, df_age_bounty
|
| 31 |
|
| 32 |
+
@st.cache_data()
|
| 33 |
def fig_app_by_arc(appearance_df, height):
|
| 34 |
fig_app_by_arc = px.histogram(appearance_df[appearance_df['Appearance'].isin(appearance_df['Appearance'].value_counts().head(20).index.tolist())],
|
| 35 |
x='Appearance',
|
|
|
|
| 48 |
)
|
| 49 |
return fig_app_by_arc
|
| 50 |
|
| 51 |
+
@st.cache_data()
|
| 52 |
def fig_app_by_arc_sunburst(appearance_df):
|
| 53 |
fig_app_by_arc_sunburst = px.sunburst(appearance_df[appearance_df['Appearance'].isin(appearance_df['Appearance'].value_counts().head(10).index.tolist())],
|
| 54 |
path = ['Appearance', 'Arc'],
|
|
|
|
| 56 |
height = 800)
|
| 57 |
return fig_app_by_arc_sunburst
|
| 58 |
|
| 59 |
+
@st.cache_data()
|
| 60 |
def fig_latest_bounty(char_details_df, height):
|
| 61 |
df = char_details_df[char_details_df['last_bounty'] > 0]
|
| 62 |
df = df.sort_values(by = "last_bounty", ascending = False)
|
|
|
|
| 73 |
)
|
| 74 |
return fig_latest_bounty
|
| 75 |
|
| 76 |
+
@st.cache_data()
|
| 77 |
def fig_latest_bounty_dist(char_details_df, height):
|
| 78 |
group_df = char_details_df[['main_crew','last_bounty']]
|
| 79 |
group_df = group_df.groupby(['main_crew']).sum()
|
|
|
|
| 88 |
)
|
| 89 |
return fig_latest_bounty_dist
|
| 90 |
|
| 91 |
+
@st.cache_data()
|
| 92 |
def fig_latest_age_to_bounty(df_age_bounty,height):
|
| 93 |
fig_latest_age_to_bounty = px.scatter(x = df_age_bounty['latest_age'],
|
| 94 |
y=df_age_bounty['last_bounty'],
|
|
|
|
| 106 |
)
|
| 107 |
return fig_latest_age_to_bounty
|
| 108 |
|
| 109 |
+
@st.cache_data()
|
| 110 |
def fig_age_to_bounty_by_crew(df_age_bounty, height):
|
| 111 |
fig_age_to_bounty_by_crew = px.scatter(x = df_age_bounty['latest_age'],
|
| 112 |
y=df_age_bounty['last_bounty'],
|
|
|
|
| 124 |
)
|
| 125 |
return fig_age_to_bounty_by_crew
|
| 126 |
|
|
|
|
| 127 |
def main():
|
| 128 |
appearance_df, char_details_df, df_age_bounty = generate_df()
|
| 129 |
# st.set_page_config(layout="wide")
|