{"id":20987343,"url":"https://github.com/alfonsokan/pba_analytics","last_synced_at":"2026-05-08T10:31:38.362Z","repository":{"id":255495940,"uuid":"852259743","full_name":"alfonsokan/pba_analytics","owner":"alfonsokan","description":"Streamlit app that provides advanced basketball statistics for the Philippine Basketball Association (PBA) 2023-2024 Season (Philippine Cup)","archived":false,"fork":false,"pushed_at":"2024-09-05T07:10:04.000Z","size":107,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T22:39:47.470Z","etag":null,"topics":["pandas","streamlit","webscraping"],"latest_commit_sha":null,"homepage":"https://pba-analytics.streamlit.app/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alfonsokan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-04T14:00:02.000Z","updated_at":"2024-09-08T15:07:10.000Z","dependencies_parsed_at":"2024-09-05T20:02:39.788Z","dependency_job_id":"167e02cd-6343-40fc-93e4-f07b85ebb020","html_url":"https://github.com/alfonsokan/pba_analytics","commit_stats":null,"previous_names":["alfonsokan/pba_analytics"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alfonsokan/pba_analytics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfonsokan%2Fpba_analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfonsokan%2Fpba_analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfonsokan%2Fpba_analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfonsokan%2Fpba_analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alfonsokan","download_url":"https://codeload.github.com/alfonsokan/pba_analytics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfonsokan%2Fpba_analytics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32776537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pandas","streamlit","webscraping"],"created_at":"2024-11-19T06:16:42.932Z","updated_at":"2026-05-08T10:31:38.342Z","avatar_url":"https://github.com/alfonsokan.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PBA Analytics App\nThis Streamlit app provides comprehensive analytics for the Philippine Basketball Association (PBA), covering a wide range of statistics. The data was meticulously web-scraped from basketball.realgm.com and processed using the Pandas library to enable dynamic filtering and analysis.\n\n\nhttps://github.com/user-attachments/assets/d5600d03-e0ed-417c-b814-67a3a7bbebae\n\n\n## Installation\n- Use the package manager pip to install the necessary libraries to run the application.\n- NOTE: If there are issues, make sure to add the line `pywin32==306` to the `requirements.txt` file.\n```bash\npip install -r requirements.txt\n```\n- Ensure the app is located in your working directory, then start it by running the following command:\n```python\nstreamlit run Home.py\n```\n## Features Summary\n- 📄 **Team Overview:** Discover the top players on each team who led in various statistical categories.\n- 🔍 **Find-a-Player:** Search for players based on specific statistical criteria, such as those averaging between 10-15 PPG and 5-10 RPG.\n- ⚔️ **Head-to-Head Comparison:** Compare the stats of two players side by side with ease.\n- 📊 **Stat Scatter:** Visualize two stats on a scatter plot for deeper insights. For example, identify the most efficient PBA scorers by plotting Points Per Game (PPG) against Field Goal Percentage (FG%).\n- 📈 **League Leaders:** Explore which players led the league in key statistical categories.\n\n## Future Developments\n- 📅 **Include Stats from Other Seasons**: Expand the app to include statistics from previous PBA seasons, allowing users to explore and compare player performance over time.\n- 🛠️ **Customizable Visualizations**: Allow users to create and save custom visualizations, making it easier to track specific stats or trends over the course of a season.\n- 📊 **Team Analytics**: Expand the analysis to team-level statistics, offering insights into team performance, strengths, and weaknesses throughout the season.\n\n## Methodology\n- 🌐 **Web Scraping**:\n  -  Libraries used: `pandas`,`bs4`,`requests`\n  -  Data was extracted from *basketball.realgm.com* using Python's web scraping libraries. This allowed us to gather detailed statistics for PBA players participating in the 2023-2024 Philippine Cup.\n\n```python\nimport requests\nfrom bs4 import BeautifulSoup\nimport pandas as pd\n\ndef table_scraper(url, class_name):\n    page = requests.get(url=url).text\n    soup = BeautifulSoup(page, 'html.parser')\n    header_cols = soup.find(class_=class_name).find('thead').find_all('th')\n    header_cols_cleaned = [header_col.text.strip() for header_col in header_cols]\n    row_data = soup.find(class_=class_name).find('tbody').find_all('tr')\n    df = pd.DataFrame(columns=header_cols_cleaned)\n\n    for index, row in enumerate(row_data):\n        content = [data.text for data in row.find_all('td')]\n        length = len(df)\n        df.loc[length] = content\n\n    for row in df.columns:\n        try:\n            # Attempt to convert the column to float type\n            df[row] = df[row].astype('float')\n            print(f\"Successfully converted {row} to float.\")\n        except ValueError:\n            # Skip conversion if an error occurs\n            print(f\"Could not convert {row} to float, skipping.\")\n            pass\n\n    return df\n```\n\nThe above Python code snippet, sourced from `notebooks/Basketball_realgm_PBA_webscraper.ipynb` within this repository, extracts a DataFrame from basketball.realgm.com. It fetches the page content, parses it to locate table headers and rows, and attempts to convert the data into a float format where possible.\n\n\u003cbr /\u003e\n\n- ⚙️ **Filtering**:\n  -  Libraries used: `pandas`, `streamlit`\n  - The pandas library was utilized to load the web-scraped dataframes and apply filters based on user input. The filtering interface was constructed using Streamlit widgets, with session state logic connecting widget selections to pandas operations\n  - This code snippet from the Stat Scatter page illustrates how to implement the page logic using Streamlit's `session state` and `pandas`\n\n```python\nimport streamlit as st\nimport pandas as pd\nimport altair as alt\n\ndf = pd.read_csv(r'datasets\\compiled_stats.csv')\n\ncol1, col2 = st.columns(2)\n\n\nwith col1:\n    st.selectbox('Y-axis', \n                   options=relevant_filters,\n                   on_change=store_value,\n                   key='_y_axis')\n    \nwith col2:\n    st.selectbox('X-axis', \n                   options=relevant_filters,\n                   on_change=store_value,\n                   key='_x_axis')\n\nfiltered_df = df[   (df['GP'] \u003e= st.session_state._games_played)\n                ]\n\nchart = alt.Chart(filtered_df).mark_circle().encode(\n    alt.X(st.session_state._x_axis).scale(zero=False),\n    alt.Y(st.session_state._y_axis).scale(zero=False, padding=1),\n    color='Team',\n    size=st.session_state._y_axis,\n    description='Player'\n)\n\n\nst.altair_chart(chart)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfonsokan%2Fpba_analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falfonsokan%2Fpba_analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfonsokan%2Fpba_analytics/lists"}