Skip to content

Commit

Permalink
streamline Lead activity assignment; fix extra space
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed Mar 15, 2024
1 parent 611a9ce commit 5129a0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ActivitySourceName,Activity,SectorSourceName,Sector,SectorType,Notes
USGS_MYB_Lead,"Primary lead, refined content, domestic ores and base bullion ",NAICS_2012_Code,331410,,
USGS_MYB_Lead,"Primary lead, refined content, domestic ores and base bullion",NAICS_2012_Code,331410,,
USGS_MYB_Lead,"Secondary lead, lead content",NAICS_2012_Code,331492,,
18 changes: 7 additions & 11 deletions flowsa/data_source_scripts/USGS_MYB.py
Original file line number Diff line number Diff line change
Expand Up @@ -2015,26 +2015,22 @@ def usgs_lead_parse(*, df_list, source, year, **_):
"Lead in base bullion",
"Lead in base bullion, lead content",
"Base bullion"]
import_export = ["Exports, lead content:",
"Imports for consumption, lead content:"]
dataframe = pd.DataFrame()
product = "production"
for df in df_list:
for index, row in df.iterrows():
if df.iloc[index]["Production"].strip() in import_export:
if df.iloc[index]["Production"].strip() == \
"Exports, lead content:":
product = "exports"
elif df.iloc[index]["Production"].strip() == \
"Imports for consumption, lead content:":
product = "imports"
if df.iloc[index]["Production"].strip() in row_to_use:
activity = df.iloc[index]["Production"].strip()
if activity == "Exports, lead content:":
product = "exports"
elif activity == "Imports for consumption, lead content:":
product = "imports"
if activity in row_to_use:
data = usgs_myb_static_variables()
data["SourceName"] = source
data["Year"] = str(year)
data["Unit"] = "Metric Tons"
data['FlowName'] = name + " " + product
data["ActivityProducedBy"] = df.iloc[index]["Production"]
data["ActivityProducedBy"] = activity
if str(df.iloc[index]["FlowAmount"]) == "--":
data["FlowAmount"] = 0
else:
Expand Down

0 comments on commit 5129a0a

Please sign in to comment.