Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python][CI] Failures on latest/nightly pandas #39732

Closed
AlenkaF opened this issue Jan 22, 2024 · 3 comments · Fixed by #39760
Closed

[Python][CI] Failures on latest/nightly pandas #39732

AlenkaF opened this issue Jan 22, 2024 · 3 comments · Fixed by #39760

Comments

@AlenkaF
Copy link
Member

AlenkaF commented Jan 22, 2024

Describe the bug, including details regarding any error messages, version, and platform.

The tests on the CI started failing with the new release of pandas (19 jan 2024, version 2.2.0) with:

=================================== FAILURES ===================================
__________________ test_array_protocol_pandas_extension_types __________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fbb44648c40>

    def test_array_protocol_pandas_extension_types(monkeypatch):
        # ARROW-7022 - ensure protocol works for Period / Interval extension dtypes
    
        storage = pa.array([1, 2, 3], type=pa.int64())
        expected = pa.ExtensionArray.from_storage(DummyExtensionType(), storage)
    
        monkeypatch.setattr(pd.arrays.PeriodArray, "__arrow_array__",
                            PandasArray__arrow_array__, raising=False)
        monkeypatch.setattr(pd.arrays.IntervalArray, "__arrow_array__",
                            PandasArray__arrow_array__, raising=False)
        for arr in [pd.period_range("2012-01-01", periods=3, freq="D").array,
                    pd.interval_range(1, 4).array]:
            result = pa.array(arr)
            assert result.equals(expected)
            result = pa.array(pd.Series(arr))
            assert result.equals(expected)
            result = pa.array(pd.Index(arr))
            assert result.equals(expected)
            result = pa.table(pd.DataFrame({'a': arr})).column('a').chunk(0)
>           assert result.equals(expected)
E           assert False
E            +  where False = <bound method Array.equals of <pyarrow.lib.Int64Array object at 0x7fbb446b7690>\n[\n  1,\n  2,\n  3\n]>(<pyarrow.lib.ExtensionArray object at 0x7fbb446b7a10>\n[\n  1,\n  2,\n  3\n])
E            +    where <bound method Array.equals of <pyarrow.lib.Int64Array object at 0x7fbb446b7690>\n[\n  1,\n  2,\n  3\n]> = <pyarrow.lib.Int64Array object at 0x7fbb446b7690>\n[\n  1,\n  2,\n  3\n].equals

usr/local/lib64/python3.11/site-packages/pyarrow/tests/test_pandas.py:4161: AssertionError
___________________ test_table_factory_function_args_pandas ____________________

    @pytest.mark.pandas
    def test_table_factory_function_args_pandas():
        import pandas as pd
    
        # from_pandas not accepting names or metadata:
>       with pytest.raises(ValueError):
E       Failed: DID NOT RAISE <class 'ValueError'>

See:
https://github.com/ursacomputing/crossbow/actions/runs/7604845464/job/20708281882
https://github.com/ursacomputing/crossbow/actions/runs/7604845540/job/20708282208

Component(s)

Python

@jorisvandenbossche
Copy link
Member

Hmm, the reason for the failure is (I suppose) related to the fact that I added __arrow_c_stream__ to pd.DataFrame.

@AlenkaF
Copy link
Member Author

AlenkaF commented Jan 22, 2024

Ah, thanks for the info! I was a bit lost to be honest =)
I guess a change in the ordering of the defined method options when converting would do?

@AlenkaF
Copy link
Member Author

AlenkaF commented Jan 22, 2024

Here:

elif hasattr(data, "__arrow_c_stream__"):
?

jorisvandenbossche pushed a commit that referenced this issue Jan 25, 2024
…39760)

This PR rearranges if-else blocks in the `table` function (`table.pxi`) so that pandas dataframe object comes before checking for `__arrow_c_stream__` and `__arrow_c_array__`.
* Closes: #39732

Authored-by: AlenkaF <frim.alenka@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
@jorisvandenbossche jorisvandenbossche added this to the 15.0.1 milestone Jan 25, 2024
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…ndas (apache#39760)

This PR rearranges if-else blocks in the `table` function (`table.pxi`) so that pandas dataframe object comes before checking for `__arrow_c_stream__` and `__arrow_c_array__`.
* Closes: apache#39732

Authored-by: AlenkaF <frim.alenka@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
raulcd pushed a commit that referenced this issue Feb 20, 2024
…39760)

This PR rearranges if-else blocks in the `table` function (`table.pxi`) so that pandas dataframe object comes before checking for `__arrow_c_stream__` and `__arrow_c_array__`.
* Closes: #39732

Authored-by: AlenkaF <frim.alenka@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
zanmato1984 pushed a commit to zanmato1984/arrow that referenced this issue Feb 28, 2024
…ndas (apache#39760)

This PR rearranges if-else blocks in the `table` function (`table.pxi`) so that pandas dataframe object comes before checking for `__arrow_c_stream__` and `__arrow_c_array__`.
* Closes: apache#39732

Authored-by: AlenkaF <frim.alenka@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
thisisnic pushed a commit to thisisnic/arrow that referenced this issue Mar 8, 2024
…ndas (apache#39760)

This PR rearranges if-else blocks in the `table` function (`table.pxi`) so that pandas dataframe object comes before checking for `__arrow_c_stream__` and `__arrow_c_array__`.
* Closes: apache#39732

Authored-by: AlenkaF <frim.alenka@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants