Skip to content

dissolve does not accept multiple columns to groupBy #304

Open
@toihr

Description

@toihr

In the GeoPandas implementation you can dissolve by multiple columns (by grouping by multiple columns) i.e.

blotch_gpd.dissolve(["obsid","tile_id"])

when this is done in dask_geopandas i obtain the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[37], line 7
      5 result3 = dgp.from_dask_dataframe(blotch_dd,geometry=result2.compute())
      6 result3 = result3.set_crs("EPSG:27700")
----> 7 result4 = result3.dissolve(["obsid","tile_id"])

File ~/.miniforge3/envs/planetary/lib/python3.9/site-packages/dask_geopandas/expr.py:733, in GeoDataFrame.dissolve(self, by, aggfunc, split_out, **kwargs)
    731     data_agg = aggfunc
    732 else:
--> 733     data_agg = {col: aggfunc for col in self.columns.drop(drop)}
    734 data_agg[self.geometry.name] = merge_geometries
    735 # dask 2022.8.1 added shuffle keyword, enabled by default if split_out > 1
    736 # starting with dask 2022.9.1, but geopandas doesn't yet work with shuffle
    737 # https://github.com/geopandas/dask-geopandas/pull/229

File ~/.miniforge3/envs/planetary/lib/python3.9/site-packages/pandas/core/indexes/base.py:7066, in Index.drop(self, labels, errors)
   7063     arr_dtype = "object" if self.dtype == "object" else None
   7064     labels = com.index_labels_to_array(labels, dtype=arr_dtype)
-> 7066 indexer = self.get_indexer_for(labels)
   7067 mask = indexer == -1
   7068 if mask.any():

File ~/.miniforge3/envs/planetary/lib/python3.9/site-packages/pandas/core/indexes/base.py:6182, in Index.get_indexer_for(self, target)
   6164 """
...
File index.pyx:351, in pandas._libs.index.IndexEngine.get_indexer()

File pandas/_libs/hashtable_class_helper.pxi:7132, in pandas._libs.hashtable.PyObjectHashTable.lookup()

TypeError: unhashable type: 'list'

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