Skip to content

Commit

Permalink
introduced slightly more customisable table view to allow for better …
Browse files Browse the repository at this point in the history
…filtering on columns
  • Loading branch information
JamieVeitch committed Dec 19, 2022
1 parent 60481e9 commit 7b2aaa7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 55 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pymongo = "*"
tqdm = "*"
jupyter = "*"
pandas = "==1.4.2"
streamlit-aggrid = "*"

[dev-packages]

Expand Down
87 changes: 51 additions & 36 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 5 additions & 19 deletions spreadsheet/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pandas as pd
from streamlit import session_state as state
import streamlit as st
from st_aggrid import GridOptionsBuilder, AgGrid, GridUpdateMode, DataReturnMode, ColumnsAutoSizeMode

from database.mongo import load_database
from analysis.preprocess import preprocess
Expand Down Expand Up @@ -80,11 +81,6 @@ def load_game_data() -> pd.DataFrame:
help="sum = all values added together, mean = average per round, std = consistency (high = inconsistent)"
"max = the maximum value achieved, min = the minimum value achieved"
)
st.multiselect(
label="View Players (Optional)",
options=sorted(ranked_games.name.unique()),
key="players"
)

if not state.group_columns or not state.data_columns:
st.stop()
Expand Down Expand Up @@ -122,20 +118,10 @@ def load_game_data() -> pd.DataFrame:
view_games = view_games[view_games["rounds_played"] > state.rounds_min]
view_games = view_games.reset_index()

if not state.players:
st.dataframe(
view_games,
use_container_width=True
)
else:
try:
st.dataframe(
view_games.set_index("name").loc[state.players].reset_index(),
use_container_width=True
)
except KeyError:
st.text("no datapoints meet the filter requirements")
st.text("if you want to filter on player name, make sure to include 'name' in Group Columns")
AgGrid(
view_games,
columns_auto_size_mode=ColumnsAutoSizeMode.FIT_ALL_COLUMNS_TO_VIEW
)


if __name__ == "__main__":
Expand Down

0 comments on commit 7b2aaa7

Please sign in to comment.