4

I installed Dask in my Jupyter notebook using the below command

!pip install “dask[complete]”

After this when I run the import command


import dask.dataframe as dd

I get the below error.

ImportError                               Traceback (most recent call last)
<ipython-input-13-99db13701da1> in <module>()
  2 import pandas as pd
  3 import dask.array as da
----> 4 import dask.dataframe as dd

D:\Anaconda\lib\site-packages\dask\dataframe\__init__.py in <module>()
  1 from __future__ import print_function, division, absolute_import
  2 
----> 3 from .core import (DataFrame, Series, Index, _Frame, map_partitions,
  4                    repartition, to_delayed)
  5 from .io import (from_array, from_pandas, from_bcolz,

D:\Anaconda\lib\site-packages\dask\dataframe\core.py in <module>()
 29 from ..base import Base, compute, tokenize, normalize_token
 30 from ..async import get_sync
---> 31 from . import methods
 32 from .utils import (meta_nonempty, make_meta, insert_meta_param_description,
 33                     raise_on_meta_error)

D:\Anaconda\lib\site-packages\dask\dataframe\methods.py in <module>()
  5 from toolz import partition
  6 
----> 7 from .utils import PANDAS_VERSION
  8 
  9 

D:\Anaconda\lib\site-packages\dask\dataframe\utils.py in <module>()
 13 import pandas as pd
 14 import pandas.util.testing as tm
---> 15 from pandas.core.common import is_datetime64tz_dtype
 16 import toolz
 17 

ImportError: cannot import name 'is_datetime64tz_dtype'

Note- My Pandas version is

pandas 0.23.4

Can anyone help me know here? Thanks.

CKE
  • 1,533
  • 19
  • 18
  • 29

3 Answers3

1

The relevant code in dask.dataframe.utils looks like

try:
    from pandas.api.types import is_datetime64tz_dtype
except ImportError:
    # pandas < 0.19.2
    from pandas.core.common import is_datetime64tz_dtype

It has been this way for over a year, suggesting that you are importing a dask that is rather old. Note that the difference between the lines in the code now and the ones reported in your traceback.

Perhaps your pip install command should have been set to upgrade (i.e., you installed dask some long time ago and forgot about it), or perhaps there is some other dependency in your system that prevents you from installing the latest dask, or simply that you are installing a new version of dask, but the old version is still the one being imported. The output of the pip command should help you identify which, and be sure to check the paths it reports versus the paths in the error above.

Also, you may find that managing environments and dependencies with conda is easier - if you are in a position to make the switch, that is.

mdurant
  • 27,272
  • 5
  • 45
  • 74
1

Try to restart your kernel after the installation. it should work.

YosDos
  • 391
  • 3
  • 13
0

Thanks to mdurant for the clue from where to import 'is_datetime64tz_dtype' My error is resolved by editing util.py

I got the same error and resolved with this change and my panda's version is '0.23.4'

You can edit your util.py file as below:D:\Anaconda\lib\site-packages\dask\dataframe\utils.py #from pandas.core.common import is_datetime64tz_dtype from pandas.api.types import is_datetime64tz_dtype

Nages
  • 763
  • 1
  • 9
  • 12