Copilot commented on code in PR #2170:
URL: https://github.com/apache/sedona/pull/2170#discussion_r2237537138


##########
python/sedona/geopandas/geoseries.py:
##########
@@ -2770,76 +2744,77 @@ def to_file(
         index: Union[bool, None] = None,
         **kwargs,
     ):
-        """
-        Write the ``GeoSeries`` to a file.
+        """Write the ``GeoSeries`` to a file.
 
         Parameters
         ----------
-        path : string
+        path : str
             File path or file handle to write to.
-        driver : string, default None
-            The format driver used to write the file.
-            If not specified, it attempts to infer it from the file extension.
-            If no extension is specified, Sedona will error.
-            Options:
-                - "geojson"
-                - "geopackage"
-                - "geoparquet"
-        schema : dict, default None
-            Not applicable to Sedona's implementation
-        index : bool, default None
-            If True, write index into one or more columns (for MultiIndex).
-            Default None writes the index into one or more columns only if
-            the index is named, is a MultiIndex, or has a non-integer data
-            type. If False, no index is written.
-        mode : string, default 'w'
-            The write mode, 'w' to overwrite the existing file and 'a' to 
append.
-            'overwrite' and 'append' are equivalent to 'w' and 'a' 
respectively.
-        crs : pyproj.CRS, default None
-            If specified, the CRS is passed to Fiona to
-            better control how the file is written. If None, GeoPandas
-            will determine the crs based on crs df attribute.
-            The value can be anything accepted
-            by :meth:`pyproj.CRS.from_user_input() 
<pyproj.crs.CRS.from_user_input>`,
-            such as an authority string (eg "EPSG:4326") or a WKT string.
-        engine : str
-            Not applicable to Sedona's implementation
-        metadata : dict[str, str], default None
-            Optional metadata to be stored in the file. Keys and values must be
-            strings. Supported only for "GPKG" driver. Not supported by Sedona
-        **kwargs :
-            Keyword args to be passed to the engine, and can be used to write
-            to multi-layer data, store data within archives (zip files), etc.
-            In case of the "pyogrio" engine, the keyword arguments are passed 
to
-            `pyogrio.write_dataframe`. In case of the "fiona" engine, the 
keyword
-            arguments are passed to fiona.open`. For more information on 
possible
-            keywords, type: ``import pyogrio; help(pyogrio.write_dataframe)``.
+        driver : str, optional
+            The format driver used to write the file, by default None. If not
+            specified, it's inferred from the file extension. Available formats
+            are "geojson", "geopackage", and "geoparquet".
+        index : bool, optional
+            If True, writes the index as a column. If False, no index is
+            written. By default None, the index is written only if it is named,
+            is a MultiIndex, or has a non-integer data type.
+        mode : str, default 'w'
+            The write mode: 'w' to overwrite the existing file or 'a' to 
append.
+        crs : pyproj.CRS, optional
+            The coordinate reference system to write. If None, it is determined
+            from the ``GeoSeries`` `crs` attribute. The value can be anything
+            accepted by :meth:`pyproj.CRS.from_user_input()`, such as an
+            authority string (e.g., "EPSG:4326") or a WKT string.
+        **kwargs
+            Additional keyword arguments passed to the underlying writing 
engine.
 
         Examples
         --------
+        >>> from shapely.geometry import Point, LineString
+        >>> from sedona.geopandas import GeoSeries
+        >>> # Note: Examples write to temporary files for demonstration
+        >>> import tempfile
+        >>> import os
+
+        Create a GeoSeries:
+        >>> gs = GeoSeries(
+        ...     [Point(0, 0), LineString([(1, 1), (2, 2)])],
+        ...     index=["a", "b"]
+        ... )
 
-        >>> gdf = GeoDataFrame({"geometry": [Point(0, 0), LineString([(0, 0), 
(1, 1)])], "int": [1, 2]}
-        >>> gdf.to_file(filepath, format="geoparquet")
-
-        With selected drivers you can also append to a file with `mode="a"`:
-
-        >>> gdf.to_file(gdf, driver="geojson", mode="a")
-
-        When the index is of non-integer dtype, index=None (default) is 
treated as True, writing the index to the file.
+        Save to a GeoParquet file:
+        >>> path_parquet = os.path.join(tempfile.gettempdir(), "data.parquet")
+        >>> gs.to_file(path_parquet, driver="geoparquet")
 
-        >>> gdf = GeoDataFrame({"geometry": [Point(0, 0)]}, index=["a", "b"])
-        >>> gdf.to_file(gdf, driver="geoparquet")
+        Append to a GeoJSON file:
+        >>> path_json = os.path.join(tempfile.gettempdir(), "data.json")
+        >>> gs.to_file(path_json, driver="geojson", mode='a')
         """
         self.to_geoframe().to_file(path, driver, index=index, **kwargs)
 
     def to_parquet(self, path, **kwargs):
-        """
-        Write the GeoSeries to a GeoParquet file.
-        Parameters:
-        - path: str
+        """Write the GeoSeries to a GeoParquet file.
+
+        Parameters
+        ----------
+        path : str
             The file path where the GeoParquet file will be written.
-        - kwargs: Any
-            Additional arguments to pass to the Sedona DataFrame output 
function.
+        **kwargs
+            Additional keyword arguments passed to the underlying writing 
function.
+
+        Returns
+        -------
+        None
+
+        Examples
+        --------
+        >>> from shapely.geometry import Point
+        >>> from sedona.geopandas import GeoSeries
+        >>> import tempfile
+        >>> import os
+        >>> gs = GeoSeries([Point(1, 1), Point(2, 2)])
+        >>> file_path = os.path.join(tempfile.gettempdir(), 
"my_geodata.parquet")
+        >>> gs.to_geoparquet(file_path)

Review Comment:
   The example calls `to_geoparquet(file_path)` but the method is 
`to_parquet(path)`. The example should be `gs.to_parquet(file_path)`.
   ```suggestion
           >>> gs.to_parquet(file_path)
   ```



-- 
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]

Reply via email to