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 21:45:48 UTC

[GitHub] [arrow] wjones127 commented on a diff in pull request #12762: ARROW-16057: [Python] Address docstrings for RecordBatch class, methods, attributes and constructor

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


##########
python/pyarrow/array.pxi:
##########
@@ -750,6 +750,28 @@ cdef class _PandasConvertible(_Weakrefable):
         Returns
         -------
         pandas.Series or pandas.DataFrame depending on type of object
+
+        Examples
+        --------
+        Convert a RecordBatch to pandas DataFrame:
+
+        >>> import pyarrow as pa
+        >>> n_legs = pa.array([2, 4, 5, 100])
+        >>> animals = pa.array(["Flamingo", "Horse", "Brittle stars", "Centipede"])
+        >>> batch = pa.RecordBatch.from_arrays([n_legs, animals],
+        ...                                     names=["n_legs", "animals"])

Review Comment:
   I'm wondering if it would be better to use the `pa.record_batch` constructor since that more closely resembles the syntax of `pd.DataFrame` that Pandas users are familiar with.
   ```suggestion
           >>> batch = pa.record_batch({"n_legs": nlegs, "animals": animals})
   ```



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