petern48 commented on code in PR #2080:
URL: https://github.com/apache/sedona/pull/2080#discussion_r2201105347
##########
python/sedona/geopandas/geoseries.py:
##########
@@ -2283,14 +2347,34 @@ def get_first_geometry_column(self) -> Union[str, None]:
),
None,
)
- return first_binary_or_geometry_col
+ if first_binary_or_geometry_col:
+ return first_binary_or_geometry_col
+
+ raise ValueError(
+ "get_first_geometry_column: No geometry column found in the
GeoSeries."
+ )
# -----------------------------------------------------------------------------
# # Utils
# -----------------------------------------------------------------------------
+def _to_spark_pandas_df(ps_series: pspd.Series) -> pspd.DataFrame:
+ return pspd.DataFrame(ps_series._psdf._internal)
+
+
+def to_bool(ps_series: pspd.Series, default: bool = False) -> pspd.Series:
+ """
+ Cast a ps.Series to bool type if it's not one, converting None values to
the default value.
+ """
+ if ps_series.dtype.name != "bool":
+ # fill None values with the default value
+ ps_series.fillna(default, inplace=True)
+
Review Comment:
I specifically do not want to call `.astype('bool')` here. PySpark's
`.fillna()` seems to be buggy in some way that's not clear to me and it
sometimes let's a `None` value slip through (which is why I have the workaround
in `def intersects`. When None values slip past the fillna call, casting it to
bool converts the value to True instead of False, which is undesirable
behavior. I'd rather leave out the astype("bool") here and let the tests fail
if for some reason the fillna doesn't convert all values to booleans.
--
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]