Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dtype inspection #4

Merged
merged 1 commit into from
May 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions datashader/data_libraries/dask.py
Original file line number Diff line number Diff line change
@@ -79,8 +79,25 @@ def default(glyph, df, schema, canvas, summary, cuda=False):
# Here be dragons
# Get the dataframe graph
graph = df.__dask_graph__()
# Guess a reasonably output dtype from combination of dataframe dtypes
dtypes = (dt for dt in df.dtypes if not isinstance(dt, pd.CategoricalDtype))

# Guess a reasonable output dtype from combination of dataframe dtypes
dtypes = []

for dt in df.dtypes:
if isinstance(dt, pd.CategoricalDtype):
continue
elif isinstance(dt, pd.api.extensions.ExtensionDtype):
# RaggedArray implementation and
# https://github.com/pandas-dev/pandas/issues/22224
try:
subdtype = dt.subtype
except AttributeError:
continue
else:
dtypes.append(subdtype)
else:
dtypes.append(dt)

dtype = np.result_type(*dtypes)
# Create a meta object so that dask.array doesn't try to look
# too closely at the type of the chunks it's wrapping