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 2021/12/23 14:49:48 UTC

[GitHub] [arrow] AlenkaF commented on a change in pull request #11985: ARROW-12545: [Python][Docs] Fill in section about Custom Schema and Field Metadata

AlenkaF commented on a change in pull request #11985:
URL: https://github.com/apache/arrow/pull/11985#discussion_r774617765



##########
File path: docs/source/python/data.rst
##########
@@ -431,4 +431,44 @@ around, so if your data is already in table form, then use
 Custom Schema and Field Metadata
 --------------------------------
 
-TODO
+The metadata used for describing the data in the schema or a field can also
+be added with the use of ``replace_schema_metadata`` or ``with_metadata``.
+
+To customize the metadata of the existing table you can use
+``replace_schema_metadata``:
+
+.. ipython:: python
+
+   table.schema.metadata # empty
+   table = table.replace_schema_metadata({"f0": "First dose"})
+   table.schema.metadata
+
+To customize the metadata of the field from the table schema you can use
+``with_metadata``:
+
+.. ipython:: python
+
+   field_f1 = table.schema.field("f1")
+   field_f1.metadata # empty
+   field_f1 = field_f1.with_metadata({"f1": "Second dose"})
+   field_f1.metadata
+
+Both options create a shallow copy of the data and do not in fact change
+Schema which is immutable. To change the metadata in the schema of the table we

Review comment:
       Yes, I guess it is not clear - will reword to be more explicit.




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