Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Method to check that two Dask Series have the same index #1112

@MarcoGorelli

Description

@MarcoGorelli

Hi - I discussed this a bit with @phofl , as I'm aiming to have zero-cost-abstraction around Dask DataFrame in Narwhals

One thing I'd like to check is how to check that two Dask Series have the same index. Or, rather, that concatenating them would not result in any index alignment

Patrick pointed me to dask_expr._expr.are_co_aligned, which seemed to work great for me until I tried using __getitem__. Here's an example:

In [21]: df = dd.from_pandas(pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}))

In [22]: dask_expr._expr.are_co_aligned(df._expr, df['a'][[1,2,0]]._expr)
Out[22]: True

This isn't quite what I was expecting - if I compute df['a'][[1,2,0]], then the index has indeed been shuffled with respect to df

Is this a bug in are_co_aligned? If not, is there another way to check that index alignment does not happen?

Thanks 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions