Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Commit 75902f3

Browse files
committed
Expand building CSV format for location detail
1 parent cde0ba7 commit 75902f3

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

firststreet/api/csv_format.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,14 @@ def format_location_detail_property(data):
757757
df['state_fips'] = pd.NA
758758
df['state_name'] = pd.NA
759759

760+
if not df['building'].isna().values.all():
761+
df = pd.concat([df.drop(['building'], axis=1), df['building'].apply(pd.Series)], axis=1)
762+
else:
763+
df.drop(['building'], axis=1, inplace=True)
764+
df['basement'] = pd.NA
765+
df['units'] = pd.NA
766+
df['stories'] = pd.NA
767+
760768
df.rename(columns={'fsid_placeholder': 'fsid'}, inplace=True)
761769
df['fsid'] = df['fsid'].apply(str)
762770
df['city_fips'] = df['city_fips'].astype('Int64').apply(str)
@@ -769,16 +777,18 @@ def format_location_detail_property(data):
769777
df['elevation'] = df['elevation'].apply(str)
770778
df['fema'] = df['fema'].apply(str)
771779
df['floorElevation'] = df['floorElevation'].apply(str)
772-
df['building'] = df['building'].apply(str)
773780
df['floodType'] = df['floodType'].apply(str)
774781
df['residential'] = df['residential'].apply(str)
775782
df['geometry'] = df['geometry'].apply(get_geom_center)
783+
df['basement'] = df['basement'].apply(str)
784+
df['units'] = df['units'].apply(str)
785+
df['stories'] = df['stories'].apply(str)
776786
df = pd.concat([df.drop(['geometry'], axis=1), df['geometry'].apply(pd.Series)], axis=1)
777787

778788
return df[['fsid', 'valid_id', 'streetNumber', 'route', 'city_fips', 'city_name', 'zipCode',
779789
'neighborhood_fips', 'neighborhood_name', 'tract_fips', 'county_fips', 'county_name', 'cd_fips',
780-
'cd_name', 'state_fips', 'state_name', 'footprintId', 'elevation', 'fema', 'floorElevation', 'building',
781-
'floodType', 'residential', 'latitude', 'longitude', 'error']]
790+
'cd_name', 'state_fips', 'state_name', 'footprintId', 'elevation', 'fema', 'floorElevation', 'basement',
791+
'units', 'stories', 'floodType', 'residential', 'latitude', 'longitude', 'error']]
782792

783793

784794
def format_location_detail_neighborhood(data):

0 commit comments

Comments
 (0)