Skip to content

Commit 83e1f08

Browse files
authored
Merge pull request #56 from nsryan2/fuel_trans
Fuel transactions NaNs to 0s
2 parents 118f090 + b4cae96 commit 83e1f08

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Includes New Features, Enhancements, and Bug Fixes.
2121
### Example
2222
Includes analysis notebooks.
2323

24-
* Analysis scripts (#31, #37)
24+
* Analysis scripts (#31, #37, #56)
2525
* Recipe update analysis (#41, #37)
2626
* Baseline recycle scenario analysis (#20, #37)
2727
* Preference analysis (#6, #15, #37)

scripts/fuel_transactions.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ def used_fuel_transactions(transactions, fuels):
1111
The types of fuel traded.
1212
"""
1313
for fuel in fuels:
14-
transactions[f'used_{fuel}_total'] = transactions.loc[
15-
transactions['Commodity'] == f'used_{fuel}']['Quantity'].cumsum()
14+
transactions[f'used_{fuel}'] = \
15+
transactions.loc[
16+
transactions['Commodity'] == f'used_{fuel}']['Quantity']
17+
transactions[f'used_{fuel}_total'] = \
18+
transactions[f'used_{fuel}'].fillna(0)
19+
transactions[f'used_{fuel}_total'] = \
20+
transactions[f'used_{fuel}_total'].cumsum()
1621

1722
return transactions
1823

@@ -29,8 +34,12 @@ def fresh_fuel_transactions(transactions, fuels):
2934
The types of fuel traded.
3035
"""
3136
for fuel in fuels:
32-
transactions[f'fresh_{fuel}_total'] = transactions.loc[
33-
transactions['Commodity'] == f'fresh_{fuel}']['Quantity'].cumsum()
37+
transactions[f'fresh_{fuel}'] = transactions.loc[
38+
transactions['Commodity'] == f'fresh_{fuel}']['Quantity']
39+
transactions[f'fresh_{fuel}_total'] = \
40+
transactions[f'fresh_{fuel}'].fillna(0)
41+
transactions[f'fresh_{fuel}_total'] = \
42+
transactions[f'fresh_{fuel}_total'].cumsum()
3443

3544
return transactions
3645

0 commit comments

Comments
 (0)