Skip to content

BUG: Series construction with dtype=ArrowBoolDtype() and index but no data fails #33899

Closed
@simonjayhawkins

Description

@simonjayhawkins
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample, a copy-pastable example

>>> import numpy as np
>>> import pandas as pd
>>>
>>> pd.__version__
'1.1.0.dev0+1436.g6016b9841'
>>>
>>> from pandas.tests.extension.arrow.arrays import ArrowBoolDtype
>>>
>>> pd.Series(index=[1, 2, 3], dtype=ArrowBoolDtype())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\simon\pandas\pandas\core\series.py", line 283, in __init__
    data, index = self._init_dict(data, index, dtype)
  File "C:\Users\simon\pandas\pandas\core\series.py", line 372, in _init_dict
    s = create_series_with_explicit_dtype(
  File "C:\Users\simon\pandas\pandas\core\construction.py", line 624, in create_series_with_explicit_dtype
    return Series(
  File "C:\Users\simon\pandas\pandas\core\series.py", line 329, in __init__
    data = sanitize_array(data, index, dtype, copy, raise_cast_failure=True)
  File "C:\Users\simon\pandas\pandas\core\construction.py", line 454, in sanitize_array
    subarr = _try_cast(data, dtype, copy, raise_cast_failure)
  File "C:\Users\simon\pandas\pandas\core\construction.py", line 537, in _try_cast
    subarr = array_type(arr, dtype=dtype, copy=copy)
  File "C:\Users\simon\pandas\pandas\tests\extension\arrow\arrays.py", line 82, in _from_sequence
    return cls.from_scalars(scalars)
  File "C:\Users\simon\pandas\pandas\tests\extension\arrow\arrays.py", line 72, in from_scalars
    arr = pa.chunked_array([pa.array(np.asarray(values))])
  File "pyarrow\array.pxi", line 265, in pyarrow.lib.array
  File "pyarrow\array.pxi", line 80, in pyarrow.lib._ndarray_to_array
  File "pyarrow\error.pxi", line 84, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays
>>>

Problem description

raises pyarrow.lib.ArrowInvalid

Expected Output

1 pa.NULL
2 pa.NULL
3 pa.NULL
dtype: arrow_bool

Output of pd.show_versions()

[paste the output of pd.show_versions() here leaving a blank line after the details tag]

Metadata

Metadata

Assignees

No one assigned

    Labels

    API - ConsistencyInternal Consistency of API/BehaviorArrowpyarrow functionalityBugConstructorsSeries/DataFrame/Index/pd.array ConstructorsExtensionArrayExtending pandas with custom dtypes or arrays.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions