Closed sdtaylor closed 4 years ago
nice, thanks @sdtaylor
There's more pandas usage in the library (e.g., in the itits module getjurisdictionvalues
) and in other modules i see some non-conditional import pandas
, but then it's not even used (e.g., gnr.py), maybe those can just be removed. do you want to address that here, or no?
oh jeez, ya, pd
is everywhere. I'll work on it more.
So, just looking at itis.py
, there a several functions which have the potential to return a dataframe. Instead of having a if dataframe and pd
for each, how do you feel about a common function like:
def maybe_dataframe(data, dataframe):
if dataframe:
if not pd:
raise RuntimeError('pandas not installed')
df = pd.DataFrame.from_records(data)
return df
else:
return data
sounds good. though it probably needs a parameter to toggle where we have the to dataframe parsing ready yet? e.g., we make a function but haven't written the code to parse to dataframe yet, so we could still use the maybe_dataframe
function everywhere, but if there's no dataframe output option yet for that function, then we just throw warning and give back the dict
thoughts?
any thoughts @sdtaylor ?
I was looking for an easy/small project to help out on and stumbled across #35. This is the branch from @ColinTalbert which removed the pandas dependency. I've rebased it with the latest master.
All tests pass locally if I use an environment without pandas installed, so I assume all hooks to it are worked out.