跳到正文
DEV Community· WhereMyRefund·· 2 天前AI 評分34

如何繪製每週聯邦退税數據圖表

How to chart weekly federal tax refund data

AI 導讀

聯邦退税報告截至 2026 年 5 月 8 日累計列出 99,138,000 筆退税,較一週前增加 1,220,000 筆,不能把累計總數標示為「本週退税」。數據集應保留每個報税季的截止日期、累計筆數及原始報告連結;只有相隔 7 天的同季報告才計算週變化,缺報時留空。

正文

A federal tax refund report ending May 8, 2026 lists 99,138,000 refunds. That's a total from the start of the filing season through the report's cutoff. Plotting it under the label ‘refunds this week’ would give the chart a completely different meaning. The reported total one week earlier was 97,918,000, so the difference between the two snapshots was 1,220,000. May 8 report · May 1 report

The same mistake can sneak into a dashboard even when the numbers are loaded correctly. Here's a way to structure the dataset so the meaning of each number survives the trip from an agency table to a chart.

Give each season its own date

The federal filing season reports compare two years side by side. The May 8 release compares Friday, May 8, 2026 with Friday, May 9, 2025. Keep a row for each season and preserve its actual cutoff date. A week number can help align points by position on a chart, but it can't replace the date that belongs to each observation. Saving both dates also gives a reviewer a straightforward way to check the number against the source. Filing season report index

Four fields are enough for a chart of refund counts. Keep the filing season, the cutoff date, the cumulative refund count and the original report URL. Store the date in ISO format and the count as an integer. If you also collect the published average refund amount, keep the dollar figure in a separate column. It's a snapshot average, and subtracting consecutive averages doesn't tell you the average amount of newly issued refunds.

Calculate differences within each season

Sort on the season and cutoff date, then subtract the previous cumulative value within the same season. Give the first row an empty difference. Its entire cumulative count doesn't automatically belong to its last seven days. If a report is missing, leave the weekly value empty as well. A change measured over fourteen days belongs on a longer interval.

from datetime import date, timedelta

previous = {}
for row in sorted(rows, key=lambda r: (r["filing_season"], r["week_ending"])):
    season = row["filing_season"]
    cutoff = date.fromisoformat(row["week_ending"])
    total = row["refunds_issued_cumulative"]
    prior = previous.get(season)
    difference = None
    if prior and cutoff - prior[0] == timedelta(days=7):
        difference = total - prior[1]
    row["refunds_issued_change_since_prior_report"] = difference
    previous[season] = cutoff, total

Before you run that loop, check that each pair of season and cutoff date is unique. If the difference turns out negative, check the two source reports. A correction to a published cumulative figure can be important data in its own right. Converting negative values to zero would hide it.

Pick a consistent refund count

The agency reports overall refunds and direct deposit refunds in separate rows. The April 17, 2026 release explains that the overall count covers refunds for current-year returns. Its direct deposit count also includes refunds for prior-year returns processed in 2026. You can compare the overall count across dates if you keep the series definition attached to the data. Mixing the two rows can produce a chart whose numbers look plausible but cover different groups of returns. April 17 report and footnote

Label what the chart can show

Use a line for cumulative refunds and a separate bar chart for the change between reports. In each tooltip, show the exact cutoff date, season and either the cumulative count or the two dates behind the difference. This makes it possible to verify a number without guessing what a chart's date label represents.

These series show the pace of refunds nationwide. They don't follow a cohort of returns from filing to payment. For a concrete example, the WhereMyRefund schedule and historical tables let you inspect the published season totals alongside a separate acceptance-week guide. This example was prepared for WhereMyRefund, an independent refund information project.

Drafted with ChatGPT. The figures and dates were checked against the linked filing season reports.

來源:DEV Community · dev.to