I am using the pandas module within a script. However, it is taking anywhere from 3-10 seconds to import pandas every time I run the script. I am using the Anaconda package for Python 2.7 and I haven't had have this issue with any other modules.
I used cProfile on a separate script that consisted of only an 'import Pandas' statement. Top results from the output are below.
C:\Users\*****\AppData\Local\Continuum\Anaconda> python -m cProfile -s cumtime test_pandas_import.py
204229 function calls (199729 primitive calls) in 3.480 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
2 0.216 0.108 3.490 1.745 __init__.py:4(<module>)
1 0.019 0.019 3.482 3.482 test_imports.py:1(<module>)
19 0.155 0.008 1.300 0.068 __init__.py:1(<module>)
1 0.024 0.024 0.895 0.895 config_init.py:11(<module>)
1 0.049 0.049 0.803 0.803 __init__.py:106(<module>)
1 0.024 0.024 0.669 0.669 format.py:2(<module>)
1 0.005 0.005 0.628 0.628 add_newdocs.py:10(<module>)
2 0.029 0.015 0.604 0.302 index.py:2(<module>)
2 0.094 0.047 0.542 0.271 __init__.py:9(<module>)
2 0.092 0.046 0.532 0.266 common.py:1(<module>)
1 0.008 0.008 0.506 0.506 type_check.py:3(<module>)
Any ideas why the import pandas statement takes so long for me, or how I might better diagnose/fix what is happening? Has anyone else experienced this issue?
The following test demonstrates the problem... the contents of testme.py is literally import pandas ; however, it takes almost 6 seconds to import pandas on my Lenovo T60.
Installing with AnacondaAfter running the installer, the user will have access to pandas and the rest of the SciPy stack without needing to install anything else, and without needing to wait for any software to be compiled.
as we know that pandas is a python package that is the best tool for data science operations. Anaconda is a python and R distribution, and it includes 100 plus python packages by default. It is also flexible to use in Windows machines as well as Linux machines.
Internally pandas imports a bunch of other stuff. There is a github issue on this topic.
Note that pytz takes a long time to import (about half of the entire pandas import) if it is version 2016.4; version 2016.7 and 2017.2 are much quicker. You might want to upgrade your pytz version; that should have a significant impact.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With