Skip to content

ENH: At top-level dataframe function for single-dispatched construction of a DataFrame #34799

Open
@TomAugspurger

Description

@TomAugspurger

Is your feature request related to a problem?

This might help with two things

  1. A coordination point for 3rd-party libraries creating objects they'd like to turn into DataFrames, and users of those libraries
  2. Possibly, simplification of DataFrame.__init__

Describe the solution you'd like

A new top-level pd.dataframe function.

def dataframe(data: Any, index: Index, columns: Index, copy: bool = False):
    """
    Create a pandas DataFrame from data.
    """

@singledispatch.register(np.ndarray)
def dataframe(...):
    pass

API breaking implications

None

Describe alternatives you've considered

xref #32844. Which attempted this for DataFrame.__init__. That was a non-starter since it exposed our internal BlockManager too publicly. #32844 (comment). So we'd need to do this on a top-level function instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closing CandidateMay be closeable, needs more eyeballsConstructorsSeries/DataFrame/Index/pd.array ConstructorsEnhancementNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions