Skip to content

DOC: Can't find mention of DataFrame accepting namedtuples as input #35438

Closed
@sjvrijn

Description

@sjvrijn

Location of the documentation

User guide 'Intro to data structures'
(alternatively DataFrame API docs)

Documentation problem

I recently only found out through a StackOverflow answer that the DataFrame constructor can take a list of namedtuples and automatically infers column names from it. Until then I had only found the DataFrame.from_records constructor, which manually requires specifying columns=Namedtuple._fields.

After searching the documentation for namedtuple, I haven't been able to find an explicit mention of constructors accepting namedtuples, while there is apparently explicit code in the constructor to deal with them nicely. Currently it only finds mentions where internal functions return rows as namedtuples.

In contrast, searching for e.g. 'dataclass' finds an explicit paragraph listing the option.

Suggested fix for documentation

I would propose adding an explicit mention and/or example somewhere that these kinds of inputs are accepted/encouraged, such that they can be easily found when searching for the 'namedtuple' keyword.

I can write a similar paragraph as for dataclasses in the intro to data structures, if that is indeed the right place for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions