[
https://issues.apache.org/jira/browse/ARROW-2106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16360117#comment-16360117
]
ASF GitHub Bot commented on ARROW-2106:
---------------------------------------
wesm commented on a change in pull request #1585: ARROW-2106: [Python] Add
conversion for a series of datetime objects
URL: https://github.com/apache/arrow/pull/1585#discussion_r167449049
##########
File path: python/pyarrow/tests/test_convert_pandas.py
##########
@@ -649,6 +649,19 @@ def test_timestamps_with_timezone(self):
_check_pandas_roundtrip(df)
+ def test_python_datetime(self):
+ # ARROW-2106
+ date_array = [datetime.today() + timedelta(days=x) for x in range(10)]
+ df = pd.DataFrame({
+ 'datetime': pd.Series(date_array, dtype=object)
+ })
+ result = pa.Table.from_pandas(df).to_pandas()
Review comment:
Can you add an assertion that the column in the result of
`pyarrow.Table.from_pandas` is `TimestampArray` (per the comment above). I
expect that is already the case
----------------------------------------------------------------
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] pyarrow.array can't take a pandas Series of python datetime objects.
> -----------------------------------------------------------------------------
>
> Key: ARROW-2106
> URL: https://issues.apache.org/jira/browse/ARROW-2106
> Project: Apache Arrow
> Issue Type: Bug
> Affects Versions: 0.8.0
> Reporter: Naveen Michaud-Agrawal
> Assignee: Uwe L. Korn
> Priority: Minor
> Labels: pull-request-available
> Fix For: 0.9.0
>
>
> {{> import pyarrow}}
> > from datetime import datetime
> > import pandas
> > dt = pandas.Series([datetime(2017, 12, 1), datetime(2017, 12, 3),
> datetime(2017, 12, 15)], dtype=object)
> > pyarrow.array(dt, from_pandas=True)
> Raises following:
> ---------------------------------------------------------------------------
> ArrowInvalid Traceback (most recent call last)
> <ipython-input-8-0d49f7fc5c49> in <module>()
> ----> 1 pyarrow.array(dt, from_pandas=True)
> array.pxi in pyarrow.lib.array()
> array.pxi in pyarrow.lib._ndarray_to_array()
> error.pxi in pyarrow.lib.check_status()
> ArrowInvalid: Error inferring Arrow type for Python object array. Got Python
> object of type datetime but can only handle these types: string, bool, float,
> int, date, time, decimal, list, array
> As far as I can tell, the issue seems to be the call to PyDate_CheckExact
> here (instead of using PyDate_Check):
> [https://github.com/apache/arrow/blob/3098c1411930259070efb571fb350304b18ddc70/cpp/src/arrow/python/numpy_to_arrow.cc#L1005]
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)