Skip to content

DOC: tail works even if n > length of DataFrame #46079

Closed
@kevinlinxc

Description

@kevinlinxc

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.tail.html

Documentation problem

It may be obvious to some, but if the n requested by tail() is greater than the length of the DataFrame, you get the entire DataFrame and no errors are thrown, and this is not mentioned in the documentation. This is useful for me because I'm trying to plot only the last 70 data points of a dataframe but the dataframe might not have 70 values yet. I think it would be reasonable to assume that one implementation would throw an out-of-bounds style exception.

Suggested fix for documentation

Add one line about how n > dataframe length is handled.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions