[ 
https://issues.apache.org/jira/browse/ARROW-3448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17393197#comment-17393197
 ] 

Joris Van den Bossche commented on ARROW-3448:
----------------------------------------------

I don't think this is actually fixed. When converting back the nested list with 
timestamp columns, we create numpy arrays with datetime64 dtype, not object 
dtype arrays with datetime objects:

{code}
>>> df = pd.DataFrame({'a': datetime_data})
>>> table = pa.table(df)
>>> table 
pyarrow.Table
a: list<item: timestamp[us]>
  child 0, item: timestamp[us]

>>> table.to_pandas()['a'][0]
array(['2015-01-05T12:00:00.000000', '2020-08-22T10:05:00.000000'],
      dtype='datetime64[us]')

>>> df['a'][0]
[datetime.datetime(2015, 1, 5, 12, 0), datetime.datetime(2020, 8, 22, 10, 5)]
{code}

But as I mentioned above, not sure we actually *want* to change this behaviour.

> [Python] Pandas roundtrip doesn't preserve list of datetime objects
> -------------------------------------------------------------------
>
>                 Key: ARROW-3448
>                 URL: https://issues.apache.org/jira/browse/ARROW-3448
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Python
>            Reporter: Krisztian Szucs
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Adding the following to the pandas_example.py::dataframe_with_lists functionn:
> {code:python}
> datetime_data = [
>      [datetime(2015, 1, 5, 12, 0, 0), datetime(2020, 8, 22, 10, 5, 0)],
>      [datetime(2024, 5, 5, 5, 49, 1), datetime(2015, 12, 24, 22, 10, 17)],
>      [datetime(1996, 4, 30, 2, 38, 11)],
>      None,
>      [datetime(1987, 1, 27, 8, 21, 59)]
> ]
> type = pa.timestamp('s'|'ms'|'us'|'ns')
> {code}
> breaks the tests cases, because the roundtrip doesn't preserve the object 
> type.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to