In a jupyter notebook, I have
import modin.pandas as pd
import utils
utils.py has import pandas as pd
Does the pd in utils.py import pandas, or modin.pandas? If the former, is there a way for me to make utils.py use modin.pandas from the jupyter notebook, without changing it in the code of utils.py
The
utilsmodule will always importpandas as pd, using theutilsmodule in another module will not change this even if you importmodins.pandas as pdin another module. This is because the symbolpdis tied to the module dictionary and this module dictionary is isolated from another module's dictionary, which essentially represents the core idea of having different namespaces for different modules.The way to use
modins.pandasinutilsis by updating the symbolpd. You can easily do this by replacing the old symbol with new symbol using thesetattrmethod: