Skip to content

Commit

Permalink
solid code, bump setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Btibert3 committed May 13, 2019
1 parent 4f121ab commit 768927a
Show file tree
Hide file tree
Showing 6 changed files with 2,069 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Pipfile.lock
.ipynb_checkpoints/
.Rproj.user
.Rhistory

pypeds.Rproj
46 changes: 45 additions & 1 deletion pypeds/ipeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def read_survey(path):
# add the survey
return(survey_file)


###### utilities to build url data

# build a valid ipeds survey url - return a dict with a survey key and url for download
Expand Down Expand Up @@ -246,3 +246,47 @@ def icay(years = None):
icay_df_final = icay_df.loc[icay_df.pypeds_init != True, ]
icay_df_final.drop(columns=['pypeds_init'], inplace=True)
return(icay_df_final)


class IC(object):
"""docstring"""

# init
def __init__(self, years=[2017]):
"""Constructor"""
self.years = years

# testing
def get_test(self):
for year in self.years:
print(year)


# method to get the data and return a dataframe
def get(self):
# setup the df
init_df = pd.DataFrame({'pypeds_init': [True]})
for year in self.years:
# assert that year is a int and length 1
assert isinstance(year, int), "year is not an integer"
assert year >= 2002 and year <= 2017, "year must be >=2002 and < 2017"
# build the SURVEY id
SURVEY = 'IC' + str(year)
# build the url
URL = "https://nces.ed.gov/ipeds/datacenter/data/{}.zip".format(SURVEY)
# return the bits as a dictionary for use later
year_info = {'url': URL, 'survey': SURVEY}
#year_info = get_efc(year)
year_fpath = zip_parser(url=year_info['url'], survey=year_info['survey'])
tmp_df = read_survey(year_fpath)
tmp_df.columns = tmp_df.columns.str.lower()
tmp_df['survey_year'] = int(year)
tmp_df['fall_year'] = int(year)
init_df = init_df.append(tmp_df, ignore_index=True, sort=False)
# print("finished hd for year {}".format(str(year)))
# finish up
# ignore pandas SettingWithCopyWarning, basically
pd.options.mode.chained_assignment = None
init_df = init_df.loc[init_df.pypeds_init != True, ]
init_df.drop(columns=['pypeds_init'], inplace=True)
return(init_df)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup

setup(name='pypeds',
version='0.1.0',
version='0.1.1',
python_requires='>=3.7',
description='Python package to work with IPEDS and other higher education datasets.',
url='https://brocktibert.com/',
Expand Down
Loading

0 comments on commit 768927a

Please sign in to comment.