This is a project which will contain the code for my Divvy bikeshare visualization project. This project takes data from the Divvy bikeshare open data initiative and uses it to model impacts of increased bicycle adoption and some current benefits gained at current levels of cycling.
-
Create appropriate database in Docker -- this project depends locally on a PostgreSQL database set up in Docker. To initialize locally, run these commands:
docker volume create postgres_volume docker run --name pg_db \ -e POSTGRES_PASSWORD=<my_secure_password_123> \ -v postgres_volume:/var/lib/postgresql/data \ -d -p 5432:5432 \ postgres -
Create a virtual environment -- For anybody who's old hat with Python, you know the drill. Create your virtual environment either with
pipor with your shiny newuvinstall.For convenience, I like to do my virtualenvs the good old fashioned way -
python3 -m venv divvy_project_env. Then once you're in the root of thedivvy_projectdirectory, runsource divvy_project_env/bin/activateto activate the env.deactivateto deactivate it. -
Install requirements.txt --
uvprovides apip-like interface, so it should be easy enough. While the virtual environment is activated, runpip install -r requirements.txt. If usinguv, you can runuv add -r requirements.txtto manage dependencies throughuvspecifically. -
Usage of components -- There are three main pieces to this project
-
extract.py -- this is pointed at the S3 bucket for the Divvy bike share service. Run this once a month to retrieve new data. When located in the project directory, use command
python3 extract.py -
transform.py -- this will scan the created directory where the CSV files are located and will load them into the database, tagging them with a new
source_file_idas appropriate. Run the commandpython3 transform.pyto load new rows into the database. -
streamlit_integration.py -- with data extracted and loaded into the database, run the command
streamlit run streamlit_integration.pyto load the Streamlit app in a new browser window.
-