Skip to content
Closed
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
4 changes: 2 additions & 2 deletions morpc/census/geos.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
"for": f"county:{','.join([morpc.CONST_COUNTY_NAME_TO_ID[x][2:6] for x in morpc.CONST_REGIONS['Mobility Region']])}"
}
},
{"regionmpo":{
{"regionfradel":{
"in": "state:39",
"for": f"county:{','.join([morpc.CONST_COUNTY_NAME_TO_ID[x][2:6] for x in morpc.CONST_REGIONS['MPO Region']])}"
"for": f"county:{','.join([morpc.CONST_COUNTY_NAME_TO_ID[x][2:6] for x in morpc.CONST_REGIONS['FRADEL']])}"
}}
]

Expand Down
23 changes: 13 additions & 10 deletions morpc/frictionless/frictionless.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,21 @@ def cast_field_types(df, schema, forceInteger:bool=False, forceInt64:bool=False,
for nullValue in schema.missing_values:
outDF = outDF.replace(nullValue, None)

if(handleMissingFields == "ignore"):
logger.info(f"Ignoring missing fields")
elif(handleMissingFields == "add"):
logger.info("Adding missing fields which is not present in dataframe")
outDF = add_missing_fields(df, schema)
else:
logger.error("Fields in schema is not present in dataframe. To handle missing fields, see argument handleMissingFields.")
raise RuntimeError

for field in schema.fields:
fieldName = field.name
fieldType = field.type
fieldType = field.type
if(not fieldName in df.columns):
if(handleMissingFields == "ignore"):
logger.info("Skipping field {} which is not present in dataframe".format(fieldName))
continue
elif(handleMissingFields == "add"):
logger.info("Adding field {} which is not present in dataframe".format(fieldName))
add_missing_fields(df, schema, fieldNames=fieldName, verbose=False)
continue
else:
logger.error("Field {} is not present in dataframe. To handle missing fields, see argument handleMissingFields.".format(fieldName))
raise RuntimeError

logger.debug("Casting field {} as type {}.".format(fieldName, fieldType))
# The following section is necessary because the pandas "int" type does not support null values. If null values are present,
# the field must be cast as "Int64" instead.
Expand Down
4 changes: 2 additions & 2 deletions morpc/morpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
CONST_REGIONS["CEDS Region"] = CONST_REGIONS["REGIONCEDS"]
CONST_REGIONS["CBSA"] = CONST_REGIONS["REGION7"] + ["Hocking","Morrow","Perry"]
CONST_REGIONS['Mobility Region'] = CONST_REGIONS['REGION7'] + ['Logan', 'Fayette']
CONST_REGIONS['MPO Region'] = ['Delaware', 'Franklin']
CONST_REGIONS['FRADEL'] = ['Delaware', 'Franklin']

# Region identifiers
# Note that the Columbus MSA already has a GEOID that is defined by the Census Bureau. See CONST_COLUMBUS_MSA_ID above.
Expand All @@ -196,7 +196,7 @@

# The following regions are comprised of collections of whole counties. Not all region definitions are county-based,
# for example the MPO region.
CONST_REGIONS_COUNTYBASED = ["REGION15","REGION10","REGION7","REGIONCEDS","REGIONCORPO","REGIONONECBUS","CBSA"]
CONST_REGIONS_COUNTYBASED = ["REGION15","REGION10","REGION7","REGIONCEDS","REGIONCORPO","REGIONONECBUS","CBSA","FRADEL"]

# County name abbreviations
## CONST_COUNTY_ABBREV maps the full county name to its three-letter abbreviation
Expand Down
Loading