Skip to content

ARROW-2603: [Python] Allow date and datetime subclassing - #2061

Closed
fjetter wants to merge 4 commits into
apache:masterfrom
fjetter:ARROW_2603/datetime_subclassing
Closed

fjetter wants to merge 4 commits into
apache:masterfrom
fjetter:ARROW_2603/datetime_subclassing

Conversation

@fjetter

@fjetter fjetter commented May 17, 2018

Copy link
Copy Markdown
Contributor

When converting a pandas dataframe holding subclasses of date/datetime objects, arrow raises an ArrowInvalid exception

import pandas as pd
import pyarrow as pa
import datetime

classMyDate(datetime.date):
    pass

date_array = [MyDate(2000, 1, 1)]
df = pd.DataFrame({"date": pd.Series(date_array, dtype=object)})

table = pa.Table.from_pandas(df)

@fjetter
fjetter force-pushed the ARROW_2603/datetime_subclassing branch from 345078c to 0d2e494 Compare May 17, 2018 14:23
@xhochy xhochy changed the title ARROW-2603 [Python] Allow date and datetime subclassing ARROW-2603: [Python] Allow date and datetime subclassing May 17, 2018

@wesm wesm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 modulo passing build

@fjetter
fjetter force-pushed the ARROW_2603/datetime_subclassing branch from 0d2e494 to 6608994 Compare May 20, 2018 13:35

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For pandas==0.22 the test works fine. I opened an issue pandas-dev/pandas#21142 but I'm not sure how arrow wants to handle this cc @wesm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a pure Pandas issue to me. We should adopt our expectation of the result to be independent of the underlying Pandas problem by adding expected_df["datetime"] = pd.to_datetime(expected_df["datetime"]) before the failing assertion.

@fjetter
fjetter force-pushed the ARROW_2603/datetime_subclassing branch from 6608994 to 6110023 Compare May 25, 2018 09:05
@fjetter
fjetter force-pushed the ARROW_2603/datetime_subclassing branch from 6110023 to cd76b3e Compare May 25, 2018 09:09
@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #2061 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2061      +/-   ##
==========================================
+ Coverage   86.35%   86.35%   +<.01%     
==========================================
  Files         242      230      -12     
  Lines       41184    40345     -839     
==========================================
- Hits        35564    34840     -724     
+ Misses       5620     5505     -115
Impacted Files Coverage Δ
cpp/src/arrow/python/numpy_to_arrow.cc 88.99% <100%> (ø) ⬆️
python/pyarrow/tests/test_convert_builtin.py 99.59% <100%> (+0.02%) ⬆️
cpp/src/arrow/python/python_to_arrow.cc 88.29% <100%> (ø) ⬆️
python/pyarrow/tests/test_convert_pandas.py 94.88% <100%> (+0.09%) ⬆️
rust/src/buffer.rs
rust/src/error.rs
rust/src/memory.rs
rust/src/list.rs
rust/src/datatypes.rs
rust/src/builder.rs
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce23c06...cd76b3e. Read the comment docs.

@wesm wesm closed this in 2fdacde Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants