Skip to content

Commit

Permalink
Merge remote-tracking branch 'dask/main' into safer-eval
Browse files Browse the repository at this point in the history
  • Loading branch information
hristog committed Apr 7, 2021
2 parents 263d4bd + 2b684d8 commit bfb9654
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions partd/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
unicode = unicode
import cPickle as pickle
from Queue import Queue, Empty

15 changes: 13 additions & 2 deletions partd/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,25 @@
from .encode import Encode
from .utils import extend, framesplit, frame


try:
# pandas >= 0.24.0
from pandas.api.types import is_extension_array_dtype
except ImportError:
def is_extension_array_dtype(dtype):
return False

try:
# Some `ExtensionArray`s can have a `.dtype` which is not a `ExtensionDtype`
# (e.g. they can be backed by a NumPy dtype). For these cases we check
# whether the instance is a `ExtensionArray`.
# https://github.com/dask/partd/issues/48
from pandas.api.extensions import ExtensionArray
def is_extension_array(x):
return isinstance(x, ExtensionArray)
except ImportError:
def is_extension_array(x):
return False


dumps = partial(pickle.dumps, protocol=pickle.HIGHEST_PROTOCOL)

Expand Down Expand Up @@ -129,7 +140,7 @@ def block_to_header_bytes(block):
elif is_datetime64tz_dtype(block):
extension = ('datetime64_tz_type', (block.values.tzinfo,))
values = values.view('i8')
elif is_extension_array_dtype(block.dtype):
elif is_extension_array_dtype(block.dtype) or is_extension_array(values):
extension = ("other", ())
else:
extension = ('numpy_type', ())
Expand Down

0 comments on commit bfb9654

Please sign in to comment.