Skip to content

Commit

Permalink
remove pandas chained assignments #91
Browse files Browse the repository at this point in the history
  • Loading branch information
hoostus committed Sep 5, 2024
1 parent 0b3513b commit 07027e2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/fava_envelope/modules/beancount_envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,29 +153,29 @@ def envelope_tables(self):
if any(regexp.match(row[0]) for regexp in self.budget_accounts):
if len(row) > 1 and row[1] is not None:
starting_balance += row[1]
self.income_df[months[0]]["Avail Income"] += starting_balance
self.income_df.loc["Avail Income", months[0]] += starting_balance

self.envelope_df.fillna(Decimal(0.00), inplace=True)

# Set available
for index, row in self.envelope_df.iterrows():
for index2, month in enumerate(months):
if index2 == 0:
self.envelope_df[month, "available"][index] = (
self.envelope_df.loc[index, (month, "available")] = (
row[month, "budgeted"] + row[month, "activity"]
)
else:
prev_available = self.envelope_df[
months[index2 - 1], "available"
][index]
if prev_available > 0 or self.negative_rollover:
self.envelope_df[month, "available"][index] = (
self.envelope_df.loc[index, (month, "available")] = (
prev_available
+ row[month, "budgeted"]
+ row[month, "activity"]
)
else:
self.envelope_df[month, "available"][index] = (
self.envelope_df.loc[index, (month, "available")] = (
row[month, "budgeted"] + row[month, "activity"]
)

Expand Down

0 comments on commit 07027e2

Please sign in to comment.