DOC: Clarify nrows behavior in read_csv #59467
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Here’s the updated summary with a note section included:
Summary:
This pull request updates the
nrows
parameter documentation forread_csv
to address ambiguity in the previous text. The original documentation was vague and did not clearly specify thatnrows
counts only the data rows returned, excluding the header, and skipped rows. The revised documentation provides a clearer definition ofnrows
and includes practical examples to better illustrate its usage, improving the overall clarity of the documentation.Note:
Thanks to the suggestions from a previous PR made by the issuer and insights from Stack Overflow (https://stackoverflow.com/questions/23853553/python-pandas-how-to-read-only-first-n-rows-of-csv-files-in), the updated documentation hopefully clarifies that
nrows
excludes rows skipped withskiprows
, and the header row. Please let me know if any examples should be added, revised, or removed to further enhance clarity. I understand that the example withskiprows
might seem obvious, but it was included to address potential confusion.