Repository navigation
ARROW-10863: [Python] Fix ExtensionArray.to_pandas to use underlying storage array - #8887
jorisvandenbossche wants to merge 2 commits into
Conversation
|
The report is for a Series of intervals. Can we add a test case for that? (will it roundtrip faithfully?) |
|
It does not yet roundtrip faithfully (it comes back as object array with dicts, as its storage type is a StructArray), because we currently only support pandas' extension types in the Table.to_pandas conversion, and not yet in the Array/ChunkedArray to_pandas conversions (eg partly covered by https://issues.apache.org/jira/browse/ARROW-9664). We are testing specific pandas dtypes in |
|
It would be nice to add a test in any case, even if it's only testing the less-than-ideal return type. |
1f38f8a to
bd3b121
Compare
|
In the end, wasn't that difficult to directly fix the full roundtrip as well, so did that + add a test for the original report. |
pitrou
left a comment
There was a problem hiding this comment.
LGTM, thank you @jorisvandenbossche
|
@github-actions crossbow submit wheel-manylinux2014-cp36m |
|
Revision: cded64c Submitted crossbow builds: ursa-labs/crossbow @ actions-796
|
| # TODO implement proper conversion for chunked array | ||
| # result = pa.table({"col": arr})["col"].to_pandas() | ||
| # expected = pd.Series(arr, name="col") | ||
| # tm.assert_series_equal(result, expected) |
There was a problem hiding this comment.
This test is failed on wheel-manylinux*-cp{36,37}*:
def test_array_to_pandas():
if LooseVersion(pd.__version__) < "1.0":
pytest.skip("ExtensionDtype __from_arrow__ protocol missing")
for arr in [pd.period_range("2012-01-01", periods=3, freq="D").array,
pd.interval_range(1, 4).array]:
result = pa.array(arr).to_pandas()
expected = pd.Series(arr)
> tm.assert_series_equal(result, expected)
E AssertionError: Attributes of Series are different
E
E Attribute "dtype" are different
E [left]: int64
E [right]: period[D]
There was a problem hiding this comment.
Hmm, maybe my skip for pandas was wrong. Is there any way to see which pandas version is being used in that wheel build? (based on the requirements-wheel-test.txt file I would assume the latest, but I don't see it anywhere in the output)
There was a problem hiding this comment.
In any case, the feature was only added in pandas 1.1, not 1.0, so the skip I added was wrong. Fixing that in #8934
No description provided.