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/08/30 08:39:18 UTC

[GitHub] [arrow-cookbook] amol- commented on a change in pull request #50: Update CSV recipe to use pyarrow.csv instead of pandas

amol- commented on a change in pull request #50:
URL: https://github.com/apache/arrow-cookbook/pull/50#discussion_r698302432



##########
File path: python/source/io.rst
##########
@@ -180,13 +177,36 @@ Writing CSV files
 =================
 
 It is currently possible to write an Arrow :class:`pyarrow.Table` to
-CSV by going through pandas. Arrow doesn't currently provide an optimized
-code path for writing to CSV.
+a CSV file using the :func:`pyarrow.csv.write_csv` function
 
 .. testcode::
 
+    arr = pa.array(range(100))
     table = pa.Table.from_arrays([arr], names=["col1"])
-    table.to_pandas().to_csv("table.csv", index=False)
+    
+    import pyarrow.csv
+    pa.csv.write_csv(table, "table.csv",
+                     write_options=pa.csv.WriteOptions(include_header=True))

Review comment:
       I saw, that's why I moved the `arr = pa.array(range(100))` into the test code, so that it's 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