Skip to main content

A package to fetch Bureau of Labor Statistics data using Streamlit

Project description

License: MIT PyPI Python: 3.8+ PyPI Version


Description

The streamlit-bls-connection package allows you to easily interact with the U.S. Bureau of Labor Statistics (BLS) API and retrieve data as pandas dataframes and display them in Streamlit !

How to use streamlit-bls-connection

To run the Streamlit app locally on your machine, follow these steps:

Installation

  1. Install the streamlit-bls-connection package and its dependencies by running the following command in your terminal or command prompt:
pip install streamlit-bls-connection

Create .py file

  1. Create a new Python script with your favorite text editor (e.g., VSCode, Spyder, Notepad++), name it app.py and copy/paste below code and save changes.
import streamlit as st
from streamlit_bls_connection import BLSConnection

# Step 1: Setup connection to US Bureau of Labor Statistics
connection = BLSConnection("bls_connection")

# Step 2: Define Input parameters for the API call
# Tip: one or multiple Series ID's* can be retrieved
seriesids_list = ['APU000074714', 'APU000072610']
start_year_str = '2014'  # start of date range
end_year_str = '2023'    # end of date range

# Step 3: Fetch data using the custom connection
dataframes_dict = connection.query(seriesids_list, start_year_str, end_year_str)

# Step 4: Create dataframes
gas_df = dataframes_dict['APU000074714']
electricity_df = dataframes_dict['APU000072610']

# Step 5: Show Dataframes in Streamlit
st.dataframe(gas_df)
st.dataframe(electricity_df)

In terminal set file path of folder containing .py file

  1. In your terminal or command prompt, navigate to the directory where your Python script is located.
cd /path/to/your/python/script

Run Streamlit App

  1. Run the Streamlit app using the following command:
streamlit run app.py
  1. See your results in the browser of your Streamlit App!

Requirements

  • Python version 3.8 and above

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For questions, suggestions, or contributions, please visit my GitHub Profile.

Reporting Issues

If you encounter any problems, have questions, or want to request a new feature, please feel free to open an issue on GitHub. I appreciate your feedback and will do our best to address any concerns promptly.

When reporting an issue, please provide as much detail as possible, including the version of the package, the Python version, and a clear description of the problem or feature request. This will help me better understand and resolve the issue quickly.

Thank you for your contributions to making this package better!

Use in Google Colab

If you want to try it out in the cloud, to see the streamlit-bls-connection with a Streamlit app in action, you can click the link below!

Open In Colab

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_bls_connection-0.7.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

streamlit_bls_connection-0.7-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_bls_connection-0.7.tar.gz.

File metadata

File hashes

Hashes for streamlit_bls_connection-0.7.tar.gz
Algorithm Hash digest
SHA256 241088c66d5909d35f5e55a57abbddf7fec09594b76a4bb53f2eceda6cb69c34
MD5 0480dc9f867379fefe401d527b5208d1
BLAKE2b-256 d57f54b58697a03a6765c25d8082726345bad169b044b726e5eecfc63074113f

See more details on using hashes here.

File details

Details for the file streamlit_bls_connection-0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_bls_connection-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 cb891d46c31d35528e9d9f7a41e3871168b9513718e518a0491368eead376508
MD5 7ecb7d37978dffdd44415f684558dcae
BLAKE2b-256 9c5f4e3f1e181f1563a1735c20ed727842ef1fc06a6a21e94f5f9457c802dd14

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page