Skip to content

DataFrame.head(0) doesn't return an empty frame #11930

Closed
@trvrm

Description

@trvrm
pandas.DataFrame({"stuff":[1,2,3,4,5]}).head(0)

returns

   stuff
0      1
1      2
2      3
3      4
4      5

I would expect an empty data frame, in the same way that

[1,2,3,4,5][0:0]

returns an empty list.

This is with pandas version 0.15.0.

The documentation (http://pandas.pydata.org/pandas-docs/version/0.17.0/generated/pandas.DataFrame.head.html) says head(n) returns 'first n rows', so I'd expect 0 rows if n is 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions