I have a function that takes a GeoSeries as input and returns a value. When I call said function over all rows in a large geodataframe (gdf) with gdf.apply(), setting the output as a new column in the dataframe, it works:
# successful:
gdf = gpd.read_file(inShp)
gdf['output_column'] = gdf.apply(lambda f: myFunction(f, arg), axis = 1)
But when I try to split the dataframe up with dask_geopandas and call the same function:
# not successful:
ddf = dask_geopandas.from_geopandas(gdf, npartitions=2)
out = ddf.apply(lambda f: myFunction(f, arg), axis = 1, meta=metaArg)
comp = out.compute()
I get this error:
AttributeError: 'GeoDataFrame' object has no attribute 'name'
The same error occurs when metaArg = ddf; ddf._meta; or gdf.
If my function is something simple such as the following, I still get the same error on out.compute():
def myFunction(gs):
return len(gs)
What am I doing wrong?
metaArg
might be wrong? (I suppose it expects a Series and not a DataFrame, that could explain the error)