rok commented on code in PR #34957:
URL: https://github.com/apache/arrow/pull/34957#discussion_r1163012303
##########
docs/source/python/extending_types.rst:
##########
@@ -357,3 +357,116 @@ pandas ``ExtensionArray``. This method should have the
following signature::
This way, you can control the conversion of a pyarrow ``Array`` of your pyarrow
extension type to a pandas ``ExtensionArray`` that can be stored in a
DataFrame.
+
+
+Canonical extension types
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In the :ref:`format_canonical_extensions` under the section **Official List**
+there is a list of canonical extension types. Here you can find an example of
how
+to implement and how to use the listed canonical extension types.
Review Comment:
Implement seems too strong here? :D
```suggestion
there is a list of canonical extension types. Here we list examples of how to
use the listed canonical extension types.
```
##########
docs/source/python/extending_types.rst:
##########
@@ -357,3 +357,116 @@ pandas ``ExtensionArray``. This method should have the
following signature::
This way, you can control the conversion of a pyarrow ``Array`` of your pyarrow
extension type to a pandas ``ExtensionArray`` that can be stored in a
DataFrame.
+
+
+Canonical extension types
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In the :ref:`format_canonical_extensions` under the section **Official List**
+there is a list of canonical extension types. Here you can find an example of
how
+to implement and how to use the listed canonical extension types.
+
+Fixed size tensor
+"""""""""""""""""
+
+Define fixed shape tensor extension type:
+
+.. code-block:: python
+
+ >>> tensor_type = pa.fixed_shape_tensor(pa.int32(), (2, 2))
+
+Create an array of tensors with storage array and defined fixed shape tensor
+extension type:
+
+.. code-block:: python
+
+ >>> arr = [[1, 2, 3, 4], [10, 20, 30, 40], [100, 200, 300, 400]]
+ >>> storage = pa.array(arr, pa.list_(pa.int32(), 4))
+ >>> tensor = pa.ExtensionArray.from_storage(tensor_type, storage)
Review Comment:
Maybe call these `tensor_array` to not confuse them with actual `Tensor`
objects?
```suggestion
>>> arr = [[1, 2, 3, 4], [10, 20, 30, 40], [100, 200, 300, 400]]
>>> storage = pa.array(arr, pa.list_(pa.int32(), 4))
>>> tensor_array = pa.ExtensionArray.from_storage(tensor_type, storage)
```
--
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]