I apologize for not being able to phrase my question more easily. I am writing a large package that makes extensive use of pandas in almost every function. My first instinct, naturally, was to create an __init__.py
as
import pandas
# then import my own submodules and other things
And then, every time I use pandas in a function, call it from the submodules as from . import pandas as pd
or from .. import pandas
, or something like that.
However, if I do this, when I load my package, pandas appears as a "submodule", i.e., there is a mypackage.pandas
. Which doesn't hurt anyone, but I'm guessing is not correct. A way to avoid this would be adding a del pandas
at the end of __init__.py
, which also doesn't seem like the correct approach.
So from now on I don't import pandas in my __init__
and import it separately inside every -function-, which works fine, but is too repetitive and prevents me from setting global pandas settings.
What is the preferred approach here? Is there a method which I am missing?
Thank you.