Skip to content

Commit

Permalink
change pkl to csv for rorco
Browse files Browse the repository at this point in the history
  • Loading branch information
R. Teal Witter committed May 22, 2024
1 parent 4c4cce7 commit fac9800
Show file tree
Hide file tree
Showing 3 changed files with 4,193 additions and 3 deletions.
14 changes: 12 additions & 2 deletions naturalexperiments/data/rorco/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
import pandas as pd
import pickle as pkl
import sklearn.preprocessing
import os
import requests

def load_rorco():
filename = __file__.replace('__init__.py', 'rorco_data.pkl')
filename = __file__.replace('__init__.py', 'rorco_data.csv')

data = pkl.load(open(filename, 'rb'))
if not os.path.exists(filename):
# Download the data
url = 'https://github.com/rtealwitter/naturalexperiments/blob/main/naturalexperiments/data/rorco/rorco_data.csv'

r = requests.get(url)
url_content = r.content
open(filename, 'wb').write(r.content)

data = pd.read_csv(filename)

# Restrict to rural schools
data = data[data['is_rural'] == 1]
Expand Down
Loading

0 comments on commit fac9800

Please sign in to comment.