Skip to content

Cannot plot values from the columns of a GeoDataFrame #105

Description

@LucaMarconato

If we have a GeoDataFrame with say, one categorical column on it, and we set color='column_name', we get this error KeyError: 'Could not find key type in .var_names or .obs.columns.' because the code only looks in the table.

This can be easily fixed using this function (not in main yet but will be there very soon) https://github.com/scverse/spatialdata/blob/2bd82d73243fc1337dc15d95a110b51be84576eb/src/spatialdata/_core/query/relational_query.py#L207

The function looks for the requested value from any place (dataframe columns, var, obs) and throws exceptions when the column is not found or is found in multiple places. You can request single columns or multiple numerical columns (as a list of column names).

Limtiations:

  • it throws an error if you try to request multiple categorical variables
  • it throws an error if you ask multiple columns that are not from the same location (e.g. one column from obs and one from var_names)

If these limitations are too strict I can relax them.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions