[
https://issues.apache.org/jira/browse/ARROW-1906?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16285410#comment-16285410
]
ASF GitHub Bot commented on ARROW-1906:
---------------------------------------
wesm opened a new pull request #1411: ARROW-1906: [Python] Do not override
user-supplied type in pyarrow.array when converting DatetimeTZ pandas data
URL: https://github.com/apache/arrow/pull/1411
cc @BryanCutler
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [Python] Creating a pyarrow.Array with timestamp of different unit is not
> casted
> --------------------------------------------------------------------------------
>
> Key: ARROW-1906
> URL: https://issues.apache.org/jira/browse/ARROW-1906
> Project: Apache Arrow
> Issue Type: Bug
> Components: Python
> Reporter: Bryan Cutler
> Assignee: Wes McKinney
> Labels: pull-request-available
> Fix For: 0.8.0
>
>
> This is similar to ARROW-1680 but slightly different in that an error is not
> raised but the unit will still remain unchanged only when using a timezone
> {noformat}
> In [47]: us_with_tz = pa.timestamp('us', tz='America/New_York')
> In [48]: s = pd.Series([val])
> In [49]: s_nyc =
> s.dt.tz_localize('tzlocal()').dt.tz_convert('America/New_York')
> In [50]: arr = pa.Array.from_pandas(s_nyc, type=us_with_tz)
> In [51]: arr.type
> Out[51]: TimestampType(timestamp[ns, tz=America/New_York])
> In [52]: arr2 = pa.Array.from_pandas(s, type=pa.timestamp('us'))
> In [53]: arr2.type
> Out[53]: TimestampType(timestamp[us])
> {noformat}
> There is an easy workaround to apply the cast after creating the
> pyarrow.Array, which seems to work fine
> {noformat}
> In [54]: arr = pa.Array.from_pandas(s_nyc).cast(us_with_tz, safe=False)
> In [55]: arr.type
> Out[55]: TimestampType(timestamp[us, tz=America/New_York])
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)