[
https://issues.apache.org/jira/browse/ARROW-2101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16427643#comment-16427643
]
Bryan Cutler commented on ARROW-2101:
-------------------------------------
I'm not exactly sure what the right behavior for this is. If you are just
staying in a Python 2 env, then it makes sense that {{str}} would correspond to
a binary type column and it doesn't cause a problem going to/from Pandas. In
PySpark, we are sending Arrow data to Java and it seems like specifying
{{pa.string()}} should lead to a string column in Java (a VarCharVector).
Currently, we do a check and "decode('utf-8')" before calling {{from_pandas}}
which works fine, but I thought maybe that pyarrow should perform a conversion
to UTF-8 automatically if the user specifies the type. However, it's also
possible that casting to UTF-8 wouldn't be wanted, e.g. if you are only in a
Python 2 env and don't mind treating it as a binary column.
I guess to sum this issue up, is {{pa.string()}} meant to correspond to an
Arrow UTF-8 type or is it special in this case as it depends on if your {{str}}
came from Python 2 or 3? cc [~wesmckinn] [~xhochy] [~pitrou] for thoughts
> [Python] from_pandas reads 'str' type as binary Arrow data with Python 2
> ------------------------------------------------------------------------
>
> Key: ARROW-2101
> URL: https://issues.apache.org/jira/browse/ARROW-2101
> Project: Apache Arrow
> Issue Type: Bug
> Components: Python
> Affects Versions: 0.8.0
> Reporter: Bryan Cutler
> Priority: Major
>
> Using Python 2, converting Pandas with 'str' data to Arrow results in Arrow
> data of binary type, even if the user supplies type information. conversion
> of 'unicode' type works to create Arrow data of string types. For example
> {code}
> In [25]: pa.Array.from_pandas(pd.Series(['a'])).type
> Out[25]: DataType(binary)
> In [26]: pa.Array.from_pandas(pd.Series(['a']), type=pa.string()).type
> Out[26]: DataType(binary)
> In [27]: pa.Array.from_pandas(pd.Series([u'a'])).type
> Out[27]: DataType(string)
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)