Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sjvrijn opened this issue Jul 28, 2020 · 1 comment · Fixed by #35507
Closed

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

sjvrijn opened this issue Jul 28, 2020 · 1 comment · Fixed by #35507
Labels
Milestone

Comments

@sjvrijn
Copy link
Contributor

sjvrijn commented Jul 28, 2020

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.

@sjvrijn sjvrijn added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 28, 2020
@sjvrijn sjvrijn changed the title DOC: DOC: Can't find mention of DataFrame accepting namedtuples as input Jul 28, 2020
@TomAugspurger
Copy link
Contributor

Thanks for the report. A note that we accept namedtuples would be welcome.

@TomAugspurger TomAugspurger removed the Needs Triage Issue that has not been reviewed by a pandas team member label Jul 29, 2020
@TomAugspurger TomAugspurger added this to the Contributions Welcome milestone Jul 29, 2020
@jreback jreback modified the milestones: Contributions Welcome, 1.2 Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants