Skip to content

DOC: iloc docs should indicate a tuple is valid #47799

Closed
@Dr-Irv

Description

@Dr-Irv

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.iloc.html

Documentation problem

In the docs, we say these are valid parameters:

  • An integer, e.g. 5.
  • A list or array of integers, e.g. [4, 3, 0].
  • A slice object with ints, e.g. 1:7.
  • A boolean array.
  • A callable function with one argument (the calling Series or DataFrame) and that returns valid output for indexing (one of the above). This is useful in method chains, when you don’t have a reference to the calling object, but would like to base your selection on some value.

But a 2D tuple is valid as well, as shown in the example at the bottom of the page. So this should be indicated in the docs.

Also, a 1D tuple like df.iloc[0:2,] works as well.

See discussion in pandas-stubs at pandas-dev/pandas-stubs#152

Suggested fix for documentation

Add tuple description to list at the top.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsIndexingRelated to indexing on series/frames, not to indexes themselvesgood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions