Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymize some of our financial data #6

Merged
merged 1 commit into from
Dec 2, 2022
Merged
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
52 changes: 46 additions & 6 deletions book/finances.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ overall_summary = overall_summary.melt(id_vars="Date", var_name="Category")
:tags: [remove-input, remove-stderr, remove-stdout]

# Plot net revenue, cumulative, and trend for next 6 months
net = alt.Chart(overall_summary.replace({"Cumulative": "Cash on Hand"}), title="Financial Summary", width=75)
net = alt.Chart(overall_summary.replace({"Cumulative": "Cash on Hand"}), title="Financial Summary (reverse time)", width=75)
yformat = alt.Axis(format="$,f")
yscale = alt.Scale(domain=[-200000, 700000])
net_br = net.mark_bar().encode(
Expand Down Expand Up @@ -158,10 +158,13 @@ for ix, row in costs.iterrows():
if "other expenses" in row["Account"].lower():
# For other expenses take the more specific category
kind = row["Account"].split(":", 1)[-1]
# For now, we are lumping contractors and employees together
# This will make it harder for people to identify salary levels
# based just on this data.
elif "professional fees" in row["Account"].lower():
kind = "Personnel Costs (contractor)"
kind = "Personnel Costs"
elif "Personnel Costs" in row["Account"]:
kind = "Personnel Costs (salaried)"
kind = "Personnel Costs"
else:
# Otherwise just take the account section
kind = row["Account"].split(":")[0].split(maxsplit=1)[-1]
Expand Down Expand Up @@ -198,7 +201,7 @@ cost_by_type.loc[:, "Sort"] = cost_by_type["Category"].map(
```{code-cell} ipython3
:tags: [remove-input, remove-stderr]

ch = alt.Chart(cost_by_type, width=CHART_WIDTH)
ch = alt.Chart(cost_by_type, width=CHART_WIDTH, title="Monthly spending by category")
ch.mark_bar().encode(
x="yearmonth(Date):O",
y=alt.Y(
Expand All @@ -212,6 +215,24 @@ ch.mark_bar().encode(
).interactive()
```

```{code-cell} ipython3
by_date = cost_by_type.set_index(["Date", "Category"])["Cost"].unstack("Category")
by_date_percentage = by_date.apply(lambda a: a / a.sum(), axis=1)
by_date_percentage = by_date_percentage.stack("Category").reset_index(name="Percent")

ch = alt.Chart(by_date_percentage, width=CHART_WIDTH, title="Monthly spending by category")
ch.mark_bar().encode(
x="yearmonth(Date):O",
y=alt.Y(
"Percent",
scale=alt.Scale(domain=[0, 1]),
axis=alt.Axis(format='%')
),
color="Category",
tooltip=["Category", "Percent"],
).interactive()
```

## Revenue

Our revenue data is defined in [the `Invoices` AirTable](https://airtable.com/appbjBTRIbgRiElkr/tblPn2utQBDEQomeq).
Expand Down Expand Up @@ -277,7 +298,22 @@ revenue_monthly = (
```{code-cell} ipython3
:tags: [remove-input, remove-stderr]

ch = alt.Chart(revenue_monthly, width=CHART_WIDTH, title="Monthly revenue by category (with 3-month average)")
ch = alt.Chart(revenue_monthly, width=CHART_WIDTH, title="Monthly revenue by category")
bar = ch.mark_bar().encode(
x="yearmonth(Date):O",
y="Amount",
color="Category",
tooltip=["Category", "Amount"],
).interactive()
bar
```

Same plots but with `grants` removed because they are quite high.

```{code-cell} ipython3
:tags: [remove-input, remove-stderr]

ch = alt.Chart(revenue_monthly.query("Category != 'Grant'"), width=CHART_WIDTH, title="Monthly revenue by category (no grants)")
bar = ch.mark_bar().encode(
x="yearmonth(Date):O",
y="Amount",
Expand Down Expand Up @@ -338,10 +374,14 @@ scatter = ch.mark_point(color="black").encode(
bar + line + scatter
```

+++ {"tags": ["remove-cell"]}

Broken down by anonymized paying community

> **Note** The below cell is removed to avoid concerns about anonymity. We should define a policy about how / when we make the identity of our partner communities public.

```{code-cell} ipython3
:tags: [remove-input, remove-stderr]
:tags: [remove-cell]

# FLAGS
ANONYMIZE_NAMES = True
Expand Down