sckott / pytaxize

python port of taxize (taxonomy toolbelt) for R
https://sckott.github.io/pytaxize/
MIT License
34 stars 13 forks source link

Remove pandas #45

Closed sdtaylor closed 4 years ago

sdtaylor commented 5 years ago

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.

sckott commented 5 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?

sdtaylor commented 5 years ago

oh jeez, ya, pd is everywhere. I'll work on it more.

sdtaylor commented 5 years ago

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
sckott commented 5 years ago

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?

sckott commented 5 years ago

any thoughts @sdtaylor ?