Selecting

Attribute(Dot) Based Selection

  • We used shape attribute to know the shape of the dataframe. Do you recall this? If you don’t remember, follow the code below.

  • Similar to that, you can use a particular column name as an attribute to select a column.

Dictionary(Bracket) Based Selection

  • Do you recall getting a value from a dictionary using key? If you don’t remember, follow the code below.

  • Similarly you can use a column name to select a column from a dataframe. df[column_name]

Selecting Multiple Columns

  • While selecting multiple columns we use double square brackets [[]].

Conditional Selection

  • Suppose you are interested to get data of ‘Jose’ from the given dataframe.

  • We can make a condition using any conditional operators discussed in ‘Introduction to Python’ course. Let’s say we want the record where ‘Name’ is ‘Jose’. We can make condition here using == conditional operator

  • This will return a series of True/False values

  • Get all the columns of the row that satisfies the condition. Here the condition is to get the rows where Name is ‘Jose’

Last updated

Was this helpful?