Javatpoint Logo
Javatpoint Logo

Pandas DataFrame.iloc[]

The DataFrame.iloc[] is used when the index label of the DataFrame is other than numeric series of 0,1,2,....,n or in the case when the user does not know the index label.

We can extract the rows by using an imaginary index position which is not visible in the DataFrame. It is an integer- based position(from 0 to length-1 of the axis), but may also be used with the boolean array.

The allowed inputs for .loc[] are:

  • Integer value, e.g. 7.
  • List or array of integers, e.g [2, 5, 6].
  • Slice object with ints, e.g., 1:9.
  • boolean array.
  • A callable function with one argument that can be the calling Series or the DataFrame. It returns valid outputs for indexing.

It can raise the IndexError if we request the index is out-of-bounds, except slice indexers, which allow the out-of-bounds indexing.

Syntax:

Parameters:

None

Returns:

It returns the DataFrame or the Series.

Example:

Output:

a1
b2
c       3
d4
Name: 0, dtype: int64

Next TopicDataFrame.isin()





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA