paleolimbot commented on code in PR #1050:
URL: https://github.com/apache/sedona-db/pull/1050#discussion_r3576234399
##########
python/sedonadb/python/sedonadb/dataframe.py:
##########
@@ -504,6 +504,49 @@ def drop(self, *cols: str) -> "DataFrame":
return DataFrame(self._ctx, self._impl.drop_columns(list(cols)))
+ def unnest(self, *columns: str) -> "DataFrame":
+ """Expand list/array column(s) so each element becomes its own row.
+
+ This is the relational form of `pandas`/`GeoPandas` `explode()`: for
+ each input row, a list-typed column is expanded to one output row per
+ element, with the other columns repeated. When several columns are
+ given, they are unnested in parallel (position by position).
+
+ A common spatial use is flattening a multi-geometry: `ST_Dump(geom)`
+ returns a list of parts, and `unnest()` turns each part into its own
+ row.
+
Review Comment:
It would be nice to show an example of this (I think you have to select() or
mutate() with `df.geometry.geo.dump()` and then unnest and then
`col("geometry")["parts"]` to get the struct field).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]