Skip to content

API: Missing support for creating a DataFrame from Python native arrays (or other objects supporting the buffer protocol) #4297

@lgautier

Description

@lgautier
import pandas
import array

x=array.array('i', range(10))

pdf = pandas.DataFrame.from_items([('a', x)])
# fails with:
# ValueError: If use all scalar values, must pass index

Also, since x has a __len__ may be the error message should not refer to a scalar.

Explicit casting to numpy arrays is a workaround, but it would seem convenient to have it done within the constructor for DataFrame:

import numpy
pdf = pandas.DataFrame.from_items([('a', numpy.asarray(x))])

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignIO DataIO issues that don't fit into a more specific label

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions