Skip to content

How to slice rows? Can it fit into the interchange, or is the standard required? #204

Closed as not planned
@MarcoGorelli

Description

@MarcoGorelli

Came across this yesterday: microsoft/vscode-jupyter#13951

        elif _VSCODE_builtins.hasattr(df, "to_pandas"):
            df = df.to_pandas().iloc[start:end]

This could be improved if they only needed to convert to pandas the part of the data which they needed, i.e.:

elif hasattr(df, "__dataframe__"):
    df = pd.api.interchange.from_dataframe(df.__dataframe__().slice_rows(start, end))

Or, if the Standard were actually available:

elif hasattr(df, "__dataframe__") and hasattr(df, "__dataframe_standard__"):
    df = pd.api.interchange.from_dataframe(df.__dataframe_standard().slice_rows(start, end).dataframe)

So, could this fit into the interchange protocol, or would filtering by rows only be possible for libraries implementing the standard?

It just seems a bit much to require the standard (especially if a separate compatibility package is required for it) if all people need to do is slice rows

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