Skip to content

Commit

Permalink
Tidy up the lighthouse command and notebook (#361)
Browse files Browse the repository at this point in the history
* Split the analyze command into separate files, using the same pattern as the extract command

* isort

* Tidy up the lighthouse command and notebook
  • Loading branch information
palewire authored Jan 11, 2023
1 parent df13673 commit 6a61e94
Show file tree
Hide file tree
Showing 2 changed files with 771 additions and 626 deletions.
16 changes: 9 additions & 7 deletions newshomepages/analyze/lighthouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ def lighthouse(output_dir: str = "./"):
qualified_df = qualified_df[~qualified_df.handle.isin(blacklist)].copy()

# Aggregate descriptive statistics for each metric
stats_list = ["count", "median", "mean", "min", "max", "std"]
agg_df = qualified_df.groupby("handle").agg(
{
"performance": ["count", "median", "mean", "min", "max", "std"],
"accessibility": ["count", "median", "mean", "min", "max", "std"],
"seo": ["count", "median", "mean", "min", "max", "std"],
"best_practices": ["count", "median", "mean", "min", "max", "std"],
}
dict(
performance=stats_list,
accessibility=stats_list,
seo=stats_list,
best_practices=stats_list,
)
)

# Flatten the dataframe
Expand All @@ -91,7 +92,8 @@ def lighthouse(output_dir: str = "./"):
)

# Write the results
flat_df.reset_index().to_csv(output_path / "lighthouse-analysis.csv", index=False)
output_list = flat_df.reset_index().to_dict(orient="records")
utils.write_csv(output_list, output_path / "lighthouse-analysis.csv")


def _color_code(val):
Expand Down
Loading

0 comments on commit 6a61e94

Please sign in to comment.