########## LIBRARIES ########## import streamlit as st import pandas as pd import numpy as np import plotly.graph_objects as go from streamlit_searchbox import st_searchbox from module.__selectpage__ import st_page_selectbox ########## DATASET ########## df = pd.read_csv('./data/join_02.csv') df['date'] = pd.to_datetime(df['date']) # Format preparation df['release_date'] = pd.to_datetime(df['release_date']) df['avg_peak_perc'] = df['avg_peak_perc'].str.rstrip('%').astype('float') df = df.dropna() ########## FUNCTION ########## ##### Adding single-player feature def add_opp_features(genre): df[genre[0]] = (df[genre[1]]==0)*1 ##### Adding feature depending on range of a base feature """Scenario of using this function For example, if we want a feature of price between $10 to $30 """ def add_range_features(arg): lower = arg[0]; upper = arg[1] name = arg[2]; genre = arg[3] condition = (df[genre]>=lower) & (df[genre] 4):value_r = 5 else: value_r = max ranges = st.slider( label=f'Select range of the {order_name.lower()} games', value = (1, value_r), # min_value=0, max_value=30, min_value=1, max_value=max, ) top_games = df_ax.gamename.unique()[ranges[0]-1:ranges[1]] # Dataframe preview dfbox(ax_name, y_name, df_ax) title = f"1.2 {ranges[1]} :blue[{ax_name}] Games with the :red[{order_name}] Monthly :blue[{y_name}]:" st.subheader(title) st.write(top_games) ##### PLOT 1 ##### # Plot 1 - markdown st.markdown("""***""") plot1_box(ax, y, order_name, ranges, df_ax, top_games) ##### PLOT 2 ##### # Plot 2 - markdown st.markdown("""***""") plot2_box(theme, y, genres, df_bx)