Copilot commented on code in PR #2032: URL: https://github.com/apache/sedona/pull/2032#discussion_r2188475116
########## python/sedona/geopandas/geoseries.py: ########## @@ -1720,13 +1720,90 @@ def to_file( raise NotImplementedError("GeoSeries.to_file() is not implemented yet.") def isna(self) -> pspd.Series: - raise NotImplementedError("GeoSeries.isna() is not implemented yet.") + """ + Detect missing values. + + Returns + ------- + A boolean Series of the same size as the GeoSeries, + True where a value is NA. + + Examples + -------- + + >>> from sedona.geopandas import GeoSeries + >>> from shapely.geometry import Polygon + >>> s = GeoSeries( + ... [Polygon([(0, 0), (1, 1), (0, 1)]), None, Polygon([])] + ... ) + >>> s + 0 POLYGON ((0 0, 1 1, 0 1, 0 0)) + 1 None + 2 POLYGON EMPTY + dtype: geometry + + >>> s.isna() + 0 False + 1 True + 2 False + dtype: bool + + See Also + -------- + GeoSeries.notna : inverse of isna + GeoSeries.is_empty : detect empty geometries + """ + col = self.get_first_geometry_column() + select = f"`{col}` IS NULL" + return ( + self._query_geometry_column(select, col, rename="isna") + .to_spark_pandas() + .astype("bool") + ) def isnull(self) -> pspd.Series: - raise NotImplementedError("GeoSeries.isnull() is not implemented yet.") + """Alias for `isna` method. See `isna` for more detail.""" + return self.isna() def notna(self) -> pspd.Series: - raise NotImplementedError("GeoSeries.notna() is not implemented yet.") + """ + Detect non-missing values. + + Returns + ------- + A boolean pandas Series of the same size as the GeoSeries, + False where a value is NA. + + Examples + -------- + + >>> from sedona.geopandas import GeoSeries + >>> from shapely.geometry import Polygon + >>> s = GeoSeries( + ... [Polygon([(0, 0), (1, 1), (0, 1)]), None, Polygon([])] + ... ) + >>> s + 0 POLYGON ((0 0, 1 1, 0 1, 0 0)) + 1 None + 2 POLYGON EMPTY + dtype: geometry + + >>> s.notna() + 0 True + 1 False + 2 True + dtype: bool + + See Also + -------- + GeoSeries.isna : inverse of notna + GeoSeries.is_empty : detect empty geometries + """ + col = self.get_first_geometry_column() + select = f"`{col}` IS NOT NULL" + return self._query_geometry_column( + select, col, rename="notna" + ).to_spark_pandas() Review Comment: The `notna` method should mirror `isna` and explicitly cast the result to boolean (`.astype("bool")`) to ensure dtype consistency with pandas. ```suggestion ).to_spark_pandas().astype("bool") ``` -- 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: issues-unsubscr...@sedona.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org