hupd / dataset-creation-utilities /create-year-lists.py
lukemelas's picture
Add dataset creation utilities
bb46e54
raw
history blame
552 Bytes
import pandas as pd
import numpy as np
from tqdm import tqdm
df = pd.read_feather("hupd_metadata_2022-02-22.feather", columns=['application_number', 'filing_date'])
assert df['filing_date'].dt.year.isnull().sum() == 2
df['year'] = df['filing_date'].dt.year.fillna(2018.0).astype(int)
years = df['year'].value_counts()
print(years)
for year in tqdm(years.index):
df_year_numbers = df['application_number'][df['year'] == year]
df_year_numbers.to_frame().to_csv(f'lists/{year}.txt', sep=' ', index=False, header=False)
print(f'saved {year}')