Skip to content

Commit

Permalink
Add standard Python .gitignore and add link to write-up in my portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
peteb206 committed Nov 14, 2023
1 parent e253fae commit 5b65e61
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 16 deletions.
164 changes: 163 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,168 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Custom
.ipynb_checkpoints
*.pyc
*.log
*.json
code_test.ipynb
.env
.env
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# canadians-in-college-baseball
Python web scraper for the Canadian Baseball Network

[Full project write-up](https://peteb206.github.io/projects/canadians-in-college-baseball/)
Python web scraper for the Canadian Baseball Network... [view full project description](https://peteb206.github.io/projects/canadians-in-college-baseball/)

## [Canadians in College Baseball](https://www.canadianbaseballnetwork.com/canadian-baseball-network-canadians-in-college)
[![scrape-schools](https://github.com/peteb206/canadians-in-college-baseball/actions/workflows/scrape-schools.yml/badge.svg)](https://github.com/peteb206/canadians-in-college-baseball/actions/workflows/scrape-schools.yml)
Expand Down
2 changes: 1 addition & 1 deletion google_sheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def update_stats_sheet():
df_filtered = df_filtered[df_filtered[stat] > 0] # Eliminate 0's

if len(df_filtered.index) > 0:
df_filtered.sort_values(by = stat, ascending = (stat == 'ERA'), ignore_index = True, inplace = True)
df_filtered.sort_values(by = [stat, 'last_name', 'first_name'], ascending = [stat == 'ERA', True, True], ignore_index = True, inplace = True)

cutoff = df_filtered[stat].iloc[9] if len(df_filtered.index) >= 10 else df_filtered[stat].iloc[-1]
df_filtered = df_filtered[df_filtered[stat] <= cutoff] if stat == 'ERA' else df_filtered[df_filtered[stat] >= cutoff]
Expand Down
23 changes: 12 additions & 11 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,17 +525,18 @@ def get_ncaa_id(x):
how = 'outer', on = ['id', 'NAME'])
else:
combined_df = df.copy()
combined_df.NAME.replace(self.__corrections__, inplace = True)
combined_df['last_name'] = combined_df.NAME.apply(lambda x: RosterPage.format_player_name(x)[1])
combined_df['first_name'] = combined_df.NAME.apply(lambda x: RosterPage.format_player_name(x)[0])
combined_df['OPS'] = combined_df.OBP.astype(float) + combined_df.SLG.astype(float)
if 'W' not in combined_df.columns: # TODO: remove this whenever NAIA/CCCAA stats pages start tracking W, L, SV, BB again
combined_df['W'] = 0
combined_df['L'] = 0
combined_df['SV'] = 0
combined_df['BB'] = 0
stat_cols = [col for stat_type in cbn_utils.stats_labels.keys() for col in cbn_utils.stats_labels[stat_type].keys()]
self.__df__ = combined_df.fillna(0).loc[:, ['id', 'last_name', 'first_name'] + stat_cols]
if type(combined_df) == pd.DataFrame:
combined_df.NAME.replace(self.__corrections__, inplace = True)
combined_df['last_name'] = combined_df.NAME.apply(lambda x: RosterPage.format_player_name(x)[1])
combined_df['first_name'] = combined_df.NAME.apply(lambda x: RosterPage.format_player_name(x)[0])
combined_df['OPS'] = combined_df.OBP.astype(float) + combined_df.SLG.astype(float)
if 'W' not in combined_df.columns: # TODO: remove this whenever NAIA/CCCAA stats pages start tracking W, L, SV, BB again
combined_df['W'] = 0
combined_df['L'] = 0
combined_df['SV'] = 0
combined_df['BB'] = 0
stat_cols = [col for stat_type in cbn_utils.stats_labels.keys() for col in cbn_utils.stats_labels[stat_type].keys()]
self.__df__ = combined_df.fillna(0).loc[:, ['id', 'last_name', 'first_name'] + stat_cols]
return self.__df__

class SchedulePage(WebPage):
Expand Down

0 comments on commit 5b65e61

Please sign in to comment.