Skip to content

Commit

Permalink
fix to use latest dca_operatingbusinesses columns
Browse files Browse the repository at this point in the history
  • Loading branch information
damonmcc committed Nov 7, 2024
1 parent 663deb8 commit c1aa3cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
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")
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

0 comments on commit c1aa3cd

Please sign in to comment.