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

fix FacDB use of latest dca_operatingbusinesses #1235

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 3 additions & 5 deletions products/facilities/facdb/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ def dca_operatingbusinesses(df: pd.DataFrame):
]
today = datetime.datetime.today()
covid_freeze = datetime.datetime.strptime("03/12/2020", "%m/%d/%Y")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't know we had references to covid in our repo!

df.license_expiration_date = pd.to_datetime(
df["license_expiration_date"], format="%m/%d/%Y"
)
df.expiration_date = pd.to_datetime(df["expiration_date"], format="%m/%d/%Y")
# fmt:off
df = df.loc[((df.license_expiration_date >= today) & (df.industry == "Scrap Metal Processor"))|((df.license_expiration_date >= covid_freeze) & (df.industry != "Scrap Metal Processor")), :]\
.loc[df.industry.isin(industry), :]
df = df.loc[((df.expiration_date >= today) & (df.business_category == "Scrap Metal Processor"))|((df.expiration_date >= covid_freeze) & (df.business_category != "Scrap Metal Processor")), :]\
.loc[df.business_category.isin(industry), :]
# fmt:on
df = sanitize_df(df)
df = FunctionBN(bin_field="bin").geocode_a_dataframe(df)
Expand Down
30 changes: 15 additions & 15 deletions products/facilities/facdb/sql/pipelines/dca_operatingbusinesses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ SELECT
uid,
source,
initcap(business_name) AS facname,
address_building AS addressnum,
address_street_name AS streetname,
address_building || ' ' || address_street_name AS address,
address_city AS city,
address_zip AS zipcode,
address_borough AS boro,
borough_code AS borocode,
building_number AS addressnum,
street1 AS streetname,
building_number || ' ' || street1 AS address,
city,
zip_code AS zipcode,
borough AS boro,
NULL AS borocode,
bin,
bbl,
(
CASE
WHEN industry LIKE '%Scrap Metal%' THEN 'Scrap Metal Processing'
WHEN industry LIKE '%Tow%' THEN 'Tow Truck Company'
ELSE concat('Commercial ', industry)
WHEN business_category LIKE '%Scrap Metal%' THEN 'Scrap Metal Processing'
WHEN business_category LIKE '%Tow%' THEN 'Tow Truck Company'
ELSE concat('Commercial ', business_category)
END
) AS factype,
(
CASE
WHEN industry = 'Scrap Metal Processor' THEN 'Solid Waste Processing'
WHEN industry = 'Parking Lot' THEN 'Parking Lots and Garages'
WHEN industry = 'Garage' THEN 'Parking Lots and Garages'
WHEN industry = 'Garage and Parking Lot' THEN 'Parking Lots and Garages'
WHEN industry = 'Tow Truck Company' THEN 'Parking Lots and Garages'
WHEN business_category = 'Scrap Metal Processor' THEN 'Solid Waste Processing'
WHEN business_category = 'Parking Lot' THEN 'Parking Lots and Garages'
WHEN business_category = 'Garage' THEN 'Parking Lots and Garages'
WHEN business_category = 'Garage and Parking Lot' THEN 'Parking Lots and Garages'
WHEN business_category = 'Tow Truck Company' THEN 'Parking Lots and Garages'
END
) AS facsubgrp,
initcap(business_name) AS opname,
Expand Down
Loading