Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Aug 31, 2024
1 parent bf01ed2 commit 8cc94b8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include LICENSE
include README.md
include cpi/cpi.db
recursive-include notebooks *
recursive-include notebooks *
7 changes: 4 additions & 3 deletions cpi/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def update(self) -> None:

# Download the TSVs
logger.debug(f"Downloading {len(self.FILE_LIST)} files from the BLS")
df_list = dict((name, self.get_df(name)) for name in self.FILE_LIST)
df_list = {name: self.get_df(name) for name in self.FILE_LIST}

# Insert the TSVs
logger.debug("Loading data into SQLite database")
Expand Down Expand Up @@ -93,12 +93,13 @@ def get_df(self, file: str) -> pd.DataFrame:
logger.error(f"Error downloading {url}")
logger.error(f"Response: {response.text}")
raise AssertionError(f"Error downloading {url} - {response.text}")

# Read in the contents as an io.StringIO object
df = pd.read_csv(io.StringIO(response.text), sep="\t")

# .strip() every value in the dataframe
df.replace('(^\s+|\s+$)', '', regex=True, inplace=True)
df_obj = df.select_dtypes("object")
df[df_obj.columns] = df_obj.apply(lambda x: x.str.strip())

# .strip every column name
df.columns = [c.strip() for c in df.columns]
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ help:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

livehtml:
sphinx-autobuild -b html $(SOURCEDIR) $(BUILDDIR)/html
sphinx-autobuild -b html $(SOURCEDIR) $(BUILDDIR)/html
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx
myst-parser
sphinx-palewire-theme
sphinx-palewire-theme
2 changes: 1 addition & 1 deletion notebooks/latest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"all": {"latest_month": "2024-07-01", "latest_change": 0.2, "previous_month": "2024-06-01", "previous_change": -0.1}, "food": {"latest_month": "2024-07-01", "latest_change": 0.2, "previous_month": "2024-06-01", "previous_change": 0.2}, "energy": {"latest_month": "2024-07-01", "latest_change": 0.0, "previous_month": "2024-06-01", "previous_change": -2.0}, "less_food_and_energy": {"latest_month": "2024-07-01", "latest_change": 0.2, "previous_month": "2024-06-01", "previous_change": 0.1}, "yoy_change": 2.9}
{"all": {"latest_month": "2024-07-01", "latest_change": 0.2, "previous_month": "2024-06-01", "previous_change": -0.1}, "food": {"latest_month": "2024-07-01", "latest_change": 0.2, "previous_month": "2024-06-01", "previous_change": 0.2}, "energy": {"latest_month": "2024-07-01", "latest_change": 0.0, "previous_month": "2024-06-01", "previous_change": -2.0}, "less_food_and_energy": {"latest_month": "2024-07-01", "latest_change": 0.2, "previous_month": "2024-06-01", "previous_change": 0.1}, "yoy_change": 2.9}

0 comments on commit 8cc94b8

Please sign in to comment.