Here are some difference between loc() and iloc():
loc() | iloc() | |
---|---|---|
Label or Integer based | loc() method is label-based which means we have to specify both the names of rows and columns that we want to filter out | while iloc() method is integer-based which means we have to just pass the integer index to select specific row/columns. |
inclusion of last element | loc() method includes the last element | while iloc() method does not include the last element. |
Input Used | Input we can use in loc() methods are: - A string - A list of strings - Slice notation using strings as the start and stop values |
Input we can use in iloc() methods are: - An integer - A list of integers - Slice notation using integers as the start and stop values |
Boolean Data Type | loc() method can accept the boolean data | while iloc() method does not accept boolean data |
Tags