You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "danepitkin (via GitHub)" <gi...@apache.org> on 2023/03/17 18:22:53 UTC

[GitHub] [arrow] danepitkin commented on a diff in pull request #34380: GH-33742: [Python] Address docstrings in Data Types classes

danepitkin commented on code in PR #34380:
URL: https://github.com/apache/arrow/pull/34380#discussion_r1139285587


##########
python/pyarrow/types.pxi:
##########
@@ -163,6 +182,18 @@ cdef class DataType(_Weakrefable):
     def num_fields(self):
         """
         The number of child fields.
+
+        Examples
+        --------
+        >>> import pyarrow as pa
+        >>> pa.int64()
+        DataType(int64)
+        >>> pa.int64().num_fields
+        0
+        >>> pa.list_(pa.string())
+        ListType(list<item: string>)
+        >>> pa.list_(pa.string()).num_fields
+        1

Review Comment:
   Optional: A struct could be a good example to show here! e.g.
   ```
   >>> struct = pa.struct([pa.field('f0', pa.int64()), pa.field('f1', pa.string())])
   >>> struct.num_fields
   2
   ```



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