Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize 2020 salary munger #324

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Generalize 2020 salary munger
  • Loading branch information
sea-kelp committed Jun 22, 2023
commit d1ee4db2e22e56dd9cf763375681f31a3c79c245
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ def match_salary_data(
merged.columns = ["salary", "overtime_pay", "officer_id"]
# Add an empty id column
merged["id"] = None
# Set the year to 2020
merged["year"] = 2020
# Only save out records with an OO ID
merged = merged[~merged.officer_id.isna()]
# Convert the salary from "$###,###.##" to a float
Expand All @@ -61,27 +59,29 @@ def match_salary_data(
return merged, missing


def main(id_path: Path, data: Path, output: Path):
def main(year: int, id_path: Path, data: Path, output: Path):
log.info("Starting import")
df = pd.read_csv(data, usecols=["Name", "Base Pay", "Overtime"])
ids = pd.read_csv(
id_path,
usecols=["id", "first name", "last name"],
)
merged, missing = match_salary_data(ids, df)
merged["year"] = year
common.write_files_with_missing(merged, missing, output)


@click.command()
@click.argument("year", type=int)
@click.argument("id_path", type=click.Path(exists=True, path_type=Path))
@click.argument("data", type=click.Path(exists=True, path_type=Path))
@click.argument("output", type=click.Path(path_type=Path))
def cli(id_path: Path, data: Path, output: Path):
def cli(year: int, id_path: Path, data: Path, output: Path):
logging.basicConfig(
format="[%(asctime)s - %(name)s - %(lineno)3d][%(levelname)s] %(message)s",
level=logging.INFO,
)
main(id_path, data, output)
main(year, id_path, data, output)


if __name__ == "__main__":
Expand Down