Skip to content

BUG: pandas.array works fine when 2-D array contains string #63112

@antareepsarkar

Description

@antareepsarkar

Pandas version checks

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

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

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

a = pd.array(np.array([[1], [2]])) #Raises an error

a = pd.array(np.array([[1], ['a']])) #Does not raise an error

Issue Description

pandas.array API mentions that it expects 1-D arrays as input. But, in some cases, it works fine with 2-D arrays.
Should not it raise an error?

Expected Behavior

It should show the same behaviour for same kind of input.

Installed Versions

Installed Versions

python : 3.12.12
OS : Windows
OS-release : 11

pandas : 2.3.3
numpy : 2.3.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugConstructorsSeries/DataFrame/Index/pd.array ConstructorsError ReportingIncorrect or improved errors from pandasNested DataData where the values are collections (lists, sets, dicts, objects, etc.).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions