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

Some kwarg names not allowed in summary reduction #1255

Open
ianthomas23 opened this issue Jul 24, 2023 · 0 comments
Open

Some kwarg names not allowed in summary reduction #1255

ianthomas23 opened this issue Jul 24, 2023 · 0 comments
Labels

Comments

@ianthomas23
Copy link
Member

Some kwarg names are not allowed in a summary reduction and produce an xarray error when trying to convert to a Dataset. Example:

import datashader as ds
import numpy as np
import pandas as pd

x = np.arange(2)
df = pd.DataFrame(dict(
    y_from = [0.0, 1.0, 0.0, 1.0, 0.0],
    y_to   = [0.0, 1.0, 1.0, 0.0, 0.5],
))

canvas = ds.Canvas(plot_height=7, plot_width=7)
agg = canvas.line(source=df, x=x, y=["y_from", "y_to"], axis=1, agg=ds.summary(x=ds.count()))

Error produced is

xarray.core.variable.MissingDimensionsError: 'x' has more than 1-dimension and the same name as one of its dimensions ('y', 'x'). xarray disallows such variables because they conflict with the coordinates used to label dimensions.

We should check before the calculations are performed if there is a kwarg name that is problematic and give a better error message. Invalid names are x and y, also n if using a *_n reduction, also the name of any categorical column used in a by reduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant