You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/06 20:08:18 UTC

[GitHub] [arrow] wjones127 commented on a diff in pull request #12783: ARROW-15431: [Python] Address docstrings in Schema

wjones127 commented on code in PR #12783:
URL: https://github.com/apache/arrow/pull/12783#discussion_r844337558


##########
python/pyarrow/types.pxi:
##########
@@ -1430,6 +1476,18 @@ cdef class Schema(_Weakrefable):
         Returns
         -------
         list of str
+
+        Examples
+        --------
+        >>> import pyarrow as pa
+        >>> schema = pa.schema([
+        ...     pa.field('n_legs', pa.int64()),
+        ...     pa.field('animals', pa.string())])
+
+        Get the names of the schema's fileds:

Review Comment:
   ```suggestion
           Get the names of the schema's fields:
   ```



##########
python/pyarrow/types.pxi:
##########
@@ -1446,11 +1504,43 @@ cdef class Schema(_Weakrefable):
         Returns
         -------
         list of DataType
+
+        Examples
+        --------
+        >>> import pyarrow as pa
+        >>> schema = pa.schema([
+        ...     pa.field('n_legs', pa.int64()),
+        ...     pa.field('animals', pa.string())])
+
+        Get the types of the schema's fileds:
+
+        >>> schema.types
+        [DataType(int64), DataType(string)]
         """
         return [field.type for field in self]
 
     @property
     def metadata(self):
+        """
+        The schema's field metadata.
+
+        Returns
+        -------
+        metadata: dict
+
+        Examples
+        --------
+        >>> import pyarrow as pa
+        >>> schema = pa.schema([
+        ...     pa.field('n_legs', pa.int64()),
+        ...     pa.field('animals', pa.string())],
+        ...     metadata={"n_legs": "Number of legs per animal"})
+
+        Get the metadata of the schema's fileds:

Review Comment:
   ```suggestion
           Get the metadata of the schema's fields:
   ```



##########
python/pyarrow/types.pxi:
##########
@@ -1367,6 +1367,39 @@ cdef class Field(_Weakrefable):
 
 
 cdef class Schema(_Weakrefable):
+    """
+    A named collection of types a.k.a schema. A schema defines the
+    column names and types in a record batch or table data structure.
+

Review Comment:
   ```suggestion
       They also contain metadata about the columns. For example, schemas 
       converted from Pandas contain metadata about their original Pandas 
       types so they can be converted back to the same types.
   ```



##########
python/pyarrow/types.pxi:
##########
@@ -1446,11 +1504,43 @@ cdef class Schema(_Weakrefable):
         Returns
         -------
         list of DataType
+
+        Examples
+        --------
+        >>> import pyarrow as pa
+        >>> schema = pa.schema([
+        ...     pa.field('n_legs', pa.int64()),
+        ...     pa.field('animals', pa.string())])
+
+        Get the types of the schema's fileds:

Review Comment:
   ```suggestion
           Get the types of the schema's fields:
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org