housing-data-coalition / rtc-eviction-viz

Eviction visualization for Right To Counsel NYC.
https://housing-data-coalition.github.io/rtc-eviction-viz/
6 stars 2 forks source link

The total count of pre-pandemic active cases don't match between the table and the cumulative graph. #43

Closed sraby closed 3 years ago

sraby commented 3 years ago

The cumulative graph of active cases states that there were 172,076 cases at the start of the pandemic, but our table of values introduced in #42 states that there were actually 218,916 cases at the start of the pandemic. We should look in to the methodology for how we calculate each count here to make sure we are counting the same way and arrive at the same number.

sraby commented 3 years ago

So, I tried scaling down the code in total-active-cases.sql to show us a cumulative count. Trimming off the last subquery, I was able to get counts of cumulative active cases that match up exactly with the count of cases in the table.

with covid_filings as ( 
    select 
        court,
        fileddate,
        propertytype,
        disposeddate,
        date_trunc('week', fileddate)::date as week_filed,
        date_trunc('week', disposeddate)::date as week_disposed
    from oca_index 
    where 
    classification = any('{Holdover,Non-Payment}') 
    and fileddate < '2021-03-21'
    --and propertytype = 'Residential' # commented out to show Statewide evictions, which includes commercial
    order by fileddate asc
    )

select 
count(*) as cases_filed,
count(*) filter (where week_disposed is not null) as cases_disposed,
count(*) - count(*) filter (where week_disposed is not null) as cases_active
from covid_filings;
sraby commented 3 years ago

SOLVED! Turns out the date in the SQL code for the table was listing the pandemic start date in 2021 instead of 2020.