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/04 09:42:28 UTC

[GitHub] [arrow] AlenkaF opened a new pull request, #12783: ARROW-15431: [Python] Address docstrings in Schema

AlenkaF opened a new pull request, #12783:
URL: https://github.com/apache/arrow/pull/12783

   This PR is adding docstring examples to:
   
   - `pyarrow.Schema` class methods and attributes.


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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on code in PR #12783:
URL: https://github.com/apache/arrow/pull/12783#discussion_r845184937


##########
python/pyarrow/types.pxi:
##########
@@ -1367,6 +1367,41 @@ 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.
+    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.
+    Warnings

Review Comment:
   ```suggestion
   
       Warnings
   ```
   
   (blank line between the title and the paragraph above)



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


[GitHub] [arrow] jorisvandenbossche closed pull request #12783: ARROW-15431: [Python] Address docstrings in Schema

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche closed pull request #12783: ARROW-15431: [Python] Address docstrings in Schema
URL: https://github.com/apache/arrow/pull/12783


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


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

Posted by GitBox <gi...@apache.org>.
AlenkaF commented on PR #12783:
URL: https://github.com/apache/arrow/pull/12783#issuecomment-1089984039

   This linting error is really strange and also happening on another PR. Will look at it in more detail later today or tomorrow.


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


[GitHub] [arrow] github-actions[bot] commented on pull request #12783: ARROW-15431: [Python] Address docstrings in Schema

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #12783:
URL: https://github.com/apache/arrow/pull/12783#issuecomment-1087338812

   https://issues.apache.org/jira/browse/ARROW-15431


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


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

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on code in PR #12783:
URL: https://github.com/apache/arrow/pull/12783#discussion_r845191617


##########
python/pyarrow/types.pxi:
##########
@@ -1446,11 +1506,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 fields:
+
+        >>> schema.types
+        [DataType(int64), DataType(string)]
         """
         return [field.type for field in self]
 
     @property
     def metadata(self):
+        """
+        The schema's field metadata.

Review Comment:
   ```suggestion
           The schema's metadata.
   ```
   
   ? (a field can also have metadata, but here it is the schema's metadata I think



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


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

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #12783:
URL: https://github.com/apache/arrow/pull/12783#issuecomment-1092606896

   Benchmark runs are scheduled for baseline = dd4215573349d10f7af9a1d0f316bfcc51b991e0 and contender = 76d064c729f5e2287bf2a2d5e02d1fb192ae5738. 76d064c729f5e2287bf2a2d5e02d1fb192ae5738 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/0f83c5aca6f244a6944868cdcec6e0ec...54897d6d08054e16acbc2a349bd95d7b/)
   [Finished :arrow_down:0.54% :arrow_up:0.04%] [test-mac-arm](https://conbench.ursa.dev/compare/runs/904df9cef7cc460fb54f8d550aad6ac8...edc4fd5e97284a83ae55abdebe664162/)
   [Failed :arrow_down:0.71% :arrow_up:0.0%] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/0b8e067caa4f4462b277c76023cc2418...eab9b4847e0e423596e79c3e545e98b4/)
   [Finished :arrow_down:0.09% :arrow_up:0.0%] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/db54de0b3adc4cbca446c8161f7e9f96...0aa7fafb32124d8ca0781b7e7f9796df/)
   Buildkite builds:
   [Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/467| `76d064c7` ec2-t3-xlarge-us-east-2>
   [Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/452| `76d064c7` test-mac-arm>
   [Failed] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/453| `76d064c7` ursa-i9-9960x>
   [Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/462| `76d064c7` ursa-thinkcentre-m75q>
   [Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/466| `dd421557` ec2-t3-xlarge-us-east-2>
   [Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/451| `dd421557` test-mac-arm>
   [Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/452| `dd421557` ursa-i9-9960x>
   [Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/461| `dd421557` ursa-thinkcentre-m75q>
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


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


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

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on code in PR #12783:
URL: https://github.com/apache/arrow/pull/12783#discussion_r842777634


##########
python/pyarrow/types.pxi:
##########
@@ -1367,6 +1367,28 @@ cdef class Field(_Weakrefable):
 
 
 cdef class Schema(_Weakrefable):
+    """
+    A named collection of types a.k.a schema.
+

Review Comment:
   Can you add a reference to `pa.schema` as the function how to create a Schema object manually? (eg with a "See Also" section)



##########
python/pyarrow/types.pxi:
##########
@@ -1687,6 +1852,15 @@ cdef class Schema(_Weakrefable):
         Returns
         -------
         schema: Schema
+
+        Examples
+        --------
+        >>> import pyarrow as pa
+        >>> schema = pa.schema([
+        ...     pa.field('n_legs', pa.int64()),
+        ...     pa.field('animals', pa.string())])
+        >>> schema.remove(1)

Review Comment:
   ```suggestion
           ...     pa.field('animals', pa.string())])
   
           Remove the second field of the schema:
   
           >>> schema.remove(1)
   ```
   
   (as general feedback point: I would add a bit more this kind of "introduction sentence" briefly stating what the example does)



##########
python/pyarrow/types.pxi:
##########
@@ -1367,6 +1367,28 @@ cdef class Field(_Weakrefable):
 
 
 cdef class Schema(_Weakrefable):
+    """
+    A named collection of types a.k.a schema.

Review Comment:
   I would maybe try to give a bit more detailed description of what a schema is? (eg that it describes the data types of a record batch or table)



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


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

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on code in PR #12783:
URL: https://github.com/apache/arrow/pull/12783#discussion_r845184937


##########
python/pyarrow/types.pxi:
##########
@@ -1367,6 +1367,41 @@ 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.
+    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.
+    Warnings

Review Comment:
   ```suggestion
   
       Warnings
   ```



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


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

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on PR #12783:
URL: https://github.com/apache/arrow/pull/12783#issuecomment-1088706819

   Linting is also failing with
   
   ```
    pyarrow.lib.Schema.to_string
   -> pyarrow.lib.Schema.to_string(self, truncate_metadata=True, show_field_metadata=True, show_schema_metadata=True)
   PR01: Parameters {'show_field_metadata', 'show_schema_metadata'} not documented
   
   pyarrow.lib.Schema.add_metadata
   -> pyarrow.lib.Schema.add_metadata(self, metadata)
   PR01: Parameters {'metadata'} not documented
   ```
   
   Not fully sure why that is happening, though (since you didn't change the Parameter sections, and those actually seem to be documented)


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