Skip to content

ERR: lib.is_xyz_array errors, some ignored #18064

Closed
@jbrockmendel

Description

@jbrockmendel

See #18054

In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: from pandas._libs import lib
In [4]: values = np.array([2, 1, 1, 2], dtype=np.int64)    # The relevant arg in TestMergeCategorical.test_other_columns
In [5]: lib.is_bool_array(values)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
Out[5]: False

In [7]: lib.is_bool_array(values.astype(bool))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
ValueError: Does not understand character buffer dtype format string ('?')
Exception ValueError: "Does not understand character buffer dtype format string ('?')" in 'pandas._libs.lib.is_bool_array' ignored
Out[7]: False

In [8]: lib.is_datetime_array(values)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-8-a5b7fc4b6701> in <module>()
----> 1 lib.is_datetime_array(values)

pandas/_libs/src/inference.pyx in pandas._libs.lib.is_datetime_array()

ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'

In [9]: lib.is_datetime_array(values.astype('datetime64[ns]'))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-9-0c109014e134> in <module>()
----> 1 lib.is_datetime_array(values.astype('datetime64[ns]'))

pandas/_libs/src/inference.pyx in pandas._libs.lib.is_datetime_array()

ValueError: cannot include dtype 'M' in a buffer

In [11]: lib.is_integer_array(values)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_integer_array' ignored
Out[11]: False

In [14]: lib.is_bytes_array(values)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bytes_array' ignored
Out[14]: False

In [15]: lib.is_bytes_array(values.astype(bytes))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
ValueError: Buffer dtype mismatch, expected 'Python object' but got a string
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got a string" in 'pandas._libs.lib.is_bytes_array' ignored
Out[15]: False

The closest thing to good news is that most of these functions are not used very much (at least not outside of inference.pyx, where maybe they behave better because of [mumble]). Four of them are explicitly tested in tests.dtypes.test_inference (is_datetime_array, is_datetime64_array, is_timdelta_array, is_timedelta64_array). Other than that, its just two uses of is_bool_array (core.common, core.internals) and one of is_datetime_array (in core.indexes.base)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functionsTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions