The pandas package was imported as below: import pandas as pd How can you display the path to this package?

Questions & AnswersCategory: PythonThe pandas package was imported as below: import pandas as pd How can you display the path to this package?
Geek Boy Staff asked 2 years ago

The pandas package was imported as below:

import pandas as pd

How can you display the path to this package?
a. pd.__path__
b. path(pd)
c. pd.file
d. pd.__file__
e. pd.path

1 Answers
Lokesh Kumar Staff answered 2 years ago

d. pd.__file__
Explanation

__file__ – the pathname of the file from which the module was loaded, if it was loaded from a file. The __file__ attribute may be missing for certain types of modules, such as C modules that are statically linked into the interpreter. For extension modules loaded dynamically from a shared library, it’s the pathname of the shared library file.