[Feature Request] move pandas to extras
🚀 Suggestion
Move pandas dependency to extras.
Motivation
Pandas is a heavy dependency, doing very little for stable baselines and quite annoying when running on a device such as Nvidia Jetson, as I need to build a wheel for it myself. I may find time to contribute this movement, if you would be interested.
### Checklist
- [x] I have checked that there is no similar issue in the repo (required)
Good point and I agree with this (heavy dependency for little functionality). @araffin what is your view on this? We could (potentially?) replace all panda functionality with other dependency-free code, unless that breaks some backwards-compatibility stuff. Changing the dependencies would also cause bit of headache to people (e.g. somebody takes an older project that does not sb3 version [they should have!], and now logger stuff would not work out of the box).
I inspected the code, so let me make a more precise suggestion:
pandas is used only in three places:
monitor/load_resultslogger/read_jsonlogger/read_csv
The last two functions are only used in tests, so they could be moved there. load_results is only used in results_plotter.
matplotlib, another dependency that I would like not to have, is only used in two places:
logger/Figureresults_plotter
in logger/Figure it is only used as a type annotation, so easy to do without.
That leaves the results_plotter as the only user of both pandas and matplotlib. So my updated proposal would be to:
- move
read_jsonto tests - move
read_csvto tests - move
load_resultstoresults_plotter - move
pandasandmatplotlibto optional dependencies in theextrasection, with the impact thatresults_plotterwill no longer work with base installation. Logger will still work. - if needed, add
pandasto optional dependenciestestssection.
Hello,
rather than changing the install behavior, I would be more in favor of making SB3 run without pandas and matplotlib, so when you install it with pip install --no-deps flag.
That would mean doing lazy import of pandas inside load_results (and other helpers) and using if typing.TYPE_CHECKING in the logger.