Select all rows and 2nd column

Selecting all the rows and only the second columns from the Dataframe.

Python3




# selecting all rows and
# 3rd column
df.iloc[ : , 2]


Output:

 

Select a row of series or dataframe by given integer index

The Dataframe.iloc[] is used to select a row of Series/Dataframe by a given integer index in Python

Similar Reads

Creating DataFrame to Select a Row by Index

Here, we are creating a Pandas Dataframe with ID, Product, Price, Color, and Discount with there some values in it....

Select the first row only

...

Selecting  0, 1, 2  rows.

Here, we are selecting the first rows using iloc, Dataframe.iloc[] method is used when the index label of a data frame is something other than numeric series....

Select rows from 0 to 2 and columns from 0 to 1

...

Select all rows and 2nd column

Here, we are selecting the first second, and third rows using iloc[0:3], starting with 0 indexes and ending with (3-1=2) index....

Select all rows and columns from 0 to 3.

...