From 7b2aaa71e82a5840f7779a33a8ec2f74973278a2 Mon Sep 17 00:00:00 2001 From: jamieveitch Date: Mon, 19 Dec 2022 02:41:51 +0000 Subject: [PATCH] introduced slightly more customisable table view to allow for better filtering on columns --- Pipfile | 1 + Pipfile.lock | 87 +++++++++++++++++++++++++------------------ spreadsheet/webapp.py | 24 +++--------- 3 files changed, 57 insertions(+), 55 deletions(-) diff --git a/Pipfile b/Pipfile index 6388530..b6a6495 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ pymongo = "*" tqdm = "*" jupyter = "*" pandas = "==1.4.2" +streamlit-aggrid = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 49d623a..3e59e7a 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "5931bb59c8c9080b0bd2ad26d3b3cc805da9f81ca6ee330bb0fe013f24ee2652" + "sha256": "512c27b12a3a2a914980d02045e430a4d531879559dc6abc1edec856ca5de859" }, "pipfile-spec": 6, "requires": { @@ -348,11 +348,11 @@ }, "importlib-metadata": { "hashes": [ - "sha256:d5059f9f1e8e41f80e9c56c2ee58811450c31984dfa625329ffd7c0dad88a73b", - "sha256:d84d17e21670ec07990e1044a99efe8d615d860fd176fc29ef5c306068fda313" + "sha256:0eafa39ba42bf225fc00e67f701d71f85aead9f878569caf13c3724f704b970f", + "sha256:404d48d62bba0b7a77ff9d405efd91501bef2e67ff4ace0bed40a0cf28c3c7cd" ], "markers": "python_version >= '3.7'", - "version": "==5.1.0" + "version": "==5.2.0" }, "ipykernel": { "hashes": [ @@ -615,37 +615,37 @@ }, "numpy": { "hashes": [ - "sha256:01dd17cbb340bf0fc23981e52e1d18a9d4050792e8fb8363cecbf066a84b827d", - "sha256:06005a2ef6014e9956c09ba07654f9837d9e26696a0470e42beedadb78c11b07", - "sha256:09b7847f7e83ca37c6e627682f145856de331049013853f344f37b0c9690e3df", - "sha256:0aaee12d8883552fadfc41e96b4c82ee7d794949e2a7c3b3a7201e968c7ecab9", - "sha256:0cbe9848fad08baf71de1a39e12d1b6310f1d5b2d0ea4de051058e6e1076852d", - "sha256:1b1766d6f397c18153d40015ddfc79ddb715cabadc04d2d228d4e5a8bc4ded1a", - "sha256:33161613d2269025873025b33e879825ec7b1d831317e68f4f2f0f84ed14c719", - "sha256:5039f55555e1eab31124a5768898c9e22c25a65c1e0037f4d7c495a45778c9f2", - "sha256:522e26bbf6377e4d76403826ed689c295b0b238f46c28a7251ab94716da0b280", - "sha256:56e454c7833e94ec9769fa0f86e6ff8e42ee38ce0ce1fa4cbb747ea7e06d56aa", - "sha256:58f545efd1108e647604a1b5aa809591ccd2540f468a880bedb97247e72db387", - "sha256:5e05b1c973a9f858c74367553e236f287e749465f773328c8ef31abe18f691e1", - "sha256:7903ba8ab592b82014713c491f6c5d3a1cde5b4a3bf116404e08f5b52f6daf43", - "sha256:8969bfd28e85c81f3f94eb4a66bc2cf1dbdc5c18efc320af34bffc54d6b1e38f", - "sha256:92c8c1e89a1f5028a4c6d9e3ccbe311b6ba53694811269b992c0b224269e2398", - "sha256:9c88793f78fca17da0145455f0d7826bcb9f37da4764af27ac945488116efe63", - "sha256:a7ac231a08bb37f852849bbb387a20a57574a97cfc7b6cabb488a4fc8be176de", - "sha256:abdde9f795cf292fb9651ed48185503a2ff29be87770c3b8e2a14b0cd7aa16f8", - "sha256:af1da88f6bc3d2338ebbf0e22fe487821ea4d8e89053e25fa59d1d79786e7481", - "sha256:b2a9ab7c279c91974f756c84c365a669a887efa287365a8e2c418f8b3ba73fb0", - "sha256:bf837dc63ba5c06dc8797c398db1e223a466c7ece27a1f7b5232ba3466aafe3d", - "sha256:ca51fcfcc5f9354c45f400059e88bc09215fb71a48d3768fb80e357f3b457e1e", - "sha256:ce571367b6dfe60af04e04a1834ca2dc5f46004ac1cc756fb95319f64c095a96", - "sha256:d208a0f8729f3fb790ed18a003f3a57895b989b40ea4dce4717e9cf4af62c6bb", - "sha256:dbee87b469018961d1ad79b1a5d50c0ae850000b639bcb1b694e9981083243b6", - "sha256:e9f4c4e51567b616be64e05d517c79a8a22f3606499941d97bb76f2ca59f982d", - "sha256:f063b69b090c9d918f9df0a12116029e274daf0181df392839661c4c7ec9018a", - "sha256:f9a909a8bae284d46bbfdefbdd4a262ba19d3bc9921b1e76126b1d21c3c34135" + "sha256:0104d8adaa3a4cc60c2777cab5196593bf8a7f416eda133be1f3803dd0838886", + "sha256:0885d9a7666cafe5f9876c57bfee34226e2b2847bfb94c9505e18d81011e5401", + "sha256:12bba5561d8118981f2f1ff069ecae200c05d7b6c78a5cdac0911f74bc71cbd1", + "sha256:2f8e0df2ecc1928ef7256f18e309c9d6229b08b5be859163f5caa59c93d53646", + "sha256:4445f472b246cad6514cc09fbb5ecb7aab09ca2acc3c16f29f8dca6c468af501", + "sha256:4d01f7832fa319a36fd75ba10ea4027c9338ede875792f7bf617f4b45056fc3a", + "sha256:4f5e78b8b710cd7cd1a8145994cfffc6ddd5911669a437777d8cedfce6c83a98", + "sha256:667b5b1f6a352419e340f6475ef9930348ae5cb7fca15f2cc3afcb530823715e", + "sha256:6e73a1f4f5b74a42abb55bc2b3d869f1b38cbc8776da5f8b66bf110284f7a437", + "sha256:73cf2c5b5a07450f20a0c8e04d9955491970177dce8df8d6903bf253e53268e0", + "sha256:7ad6a024a32ee61d18f5b402cd02e9c0e22c0fb9dc23751991b3a16d209d972e", + "sha256:8b1ddfac6a82d4f3c8e99436c90b9c2c68c0bb14658d1684cdd00f05fab241f5", + "sha256:90075ef2c6ac6397d0035bcd8b298b26e481a7035f7a3f382c047eb9c3414db0", + "sha256:9387c7d6d50e8f8c31e7bfc034241e9c6f4b3eb5db8d118d6487047b922f82af", + "sha256:9af91f794d2d3007d91d749ebc955302889261db514eb24caef30e03e8ec1e41", + "sha256:ab11f6a7602cf8ea4c093e091938207de3068c5693a0520168ecf4395750f7ea", + "sha256:ac4fe68f1a5a18136acebd4eff91aab8bed00d1ef2fdb34b5d9192297ffbbdfc", + "sha256:ada6c1e9608ceadaf7020e1deea508b73ace85560a16f51bef26aecb93626a72", + "sha256:c4ab7c9711fe6b235e86487ca74c1b092a6dd59a3cb45b63241ea0a148501853", + "sha256:cec79ff3984b2d1d103183fc4a3361f5b55bbb66cb395cbf5a920a4bb1fd588d", + "sha256:cf8960f72997e56781eb1c2ea256a70124f92a543b384f89e5fb3503a308b1d3", + "sha256:d7f223554aba7280e6057727333ed357b71b7da7422d02ff5e91b857888c25d1", + "sha256:dbb0490f0a880700a6cc4d000384baf19c1f4df59fff158d9482d4dbbca2b239", + "sha256:e63d2157f9fc98cc178870db83b0e0c85acdadd598b134b00ebec9e0db57a01f", + "sha256:ec3e5e8172a0a6a4f3c2e7423d4a8434c41349141b04744b11a90e017a95bad5", + "sha256:f3c4a9a9f92734a4728ddbd331e0124eabbc968a0359a506e8e74a9b0d2d419b", + "sha256:f9168790149f917ad8e3cf5047b353fefef753bd50b07c547da0bdf30bc15d91", + "sha256:fe44e925c68fb5e8db1334bf30ac1a1b6b963b932a19cf41d2e899cf02f36aab" ], "markers": "python_version >= '3.8'", - "version": "==1.23.5" + "version": "==1.24.0" }, "packaging": { "hashes": [ @@ -1045,6 +1045,13 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.8.2" }, + "python-decouple": { + "hashes": [ + "sha256:2838cdf77a5cf127d7e8b339ce14c25bceb3af3e674e039d4901ba16359968c7", + "sha256:6cf502dc963a5c642ea5ead069847df3d916a6420cad5599185de6bab11d8c2e" + ], + "version": "==3.6" + }, "python-json-logger": { "hashes": [ "sha256:3b03487b14eb9e4f77e4fc2a023358b5394b82fd89cecf5586259baed57d8c6f", @@ -1055,10 +1062,10 @@ }, "pytz": { "hashes": [ - "sha256:222439474e9c98fced559f1709d89e6c9cbf8d79c794ff3eb9f8800064291427", - "sha256:e89512406b793ca39f5971bc999cc538ce125c0e51c27941bef4568b460095e2" + "sha256:7ccfae7b4b2c067464a6733c6261673fdb8fd1be905460396b97a073e9fa683a", + "sha256:93007def75ae22f7cd991c84e02d434876818661f8df9ad5df9e950ff4e52cfd" ], - "version": "==2022.6" + "version": "==2022.7" }, "pytz-deprecation-shim": { "hashes": [ @@ -1302,6 +1309,14 @@ "index": "pypi", "version": "==1.15.1" }, + "streamlit-aggrid": { + "hashes": [ + "sha256:c5202347b1257c4246ef3541b233866f57bc930b97040be58b059093c4fee22e", + "sha256:d96edb102df98450f3b6bcf5a52b64e6ceef9678e82e2dba9cfef074e7f134ab" + ], + "index": "pypi", + "version": "==0.3.3" + }, "terminado": { "hashes": [ "sha256:6ccbbcd3a4f8a25a5ec04991f39a0b8db52dfcd487ea0e578d977e6752380333", diff --git a/spreadsheet/webapp.py b/spreadsheet/webapp.py index 131987e..b704dec 100644 --- a/spreadsheet/webapp.py +++ b/spreadsheet/webapp.py @@ -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 @@ -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() @@ -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__":