Skip to content

Commit 2b37209

Browse files
committed
fuel transactions NaNs to 0s
1 parent 118f090 commit 2b37209

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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)