-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
DOC: Document that DataFrame.from_records()'s columns argument also acts as "include" #59670
Comments
Thanks for the report! PRs to improve the docs here are welcome! |
take |
@rhshadrach
For documentation purposes, I'm considering treating the dictionary-based input as the ideal case and instructing users to convert their data into dictionaries if they want to filter or reorder columns using the columns parameter. However, as this is my first time contributing to the documentation, I'd greatly appreciate your guidance on the best approach to document these nuances. |
It seems like this could be a bug because it seems to contradict the current documentation (that the argument reorders the columns if column names are provided). If this case is fixed for reordering, the behavior for filtering could be fixed at the same time.
This seems to be consistent with the current documentation because the documentation only says that reordering occurs if names are provided (and this limitation can be the same for filtering). As for raising an error when fewer names are provided, the documentation doesn't explicitly say an error will happen in that case, but it's not surprising it would, IMO. |
Yeah, that's understandable. If the bug is fixed, we can say that the Thanks for the insights, @cjerdonek. |
Pandas version checks
main
hereLocation of the documentation
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.from_records.html
Documentation problem
Currently, it's not clear from the
DataFrame.from_records()
docs that thecolumns
argument tofrom_records()
also has the effect of what aninclude
argument (orusecols
) would do. Indeed, the current wording once led someone to file a feature request asking for aninclude
argument to be added: #15319However, the request was later closed when the maintainers realized the
columns
argument already does this (but it's not documented, hence this issue).Suggested fix for documentation
Add a sentence or phrase to the documentation of the
columns
argument that the argument also has the effect of limiting the DataFrame to including only the columns specified. This isn't implied by the current wording, or it's at least a little ambiguous.The text was updated successfully, but these errors were encountered: