iloc, 1] Day Thu 14.44 Fri 10.51 Name: Temperature, dtype: float64 > df. Here are the equivalent statements using iloc: > df. Similarly, a list of integer values can be passed to iloc to select multiple rows or columns. ![]() loc] Temperature 10.51 Wind 26 Name: Fri, dtype: object loc, 'Temperature'] Day Thu 14.44 Fri 10.51 Name: Temperature, dtype: float64 # Multiple columns > df. We can pass a list of labels to loc to select multiple rows or columns: # Multiple rows > df. loc and iloc will return a Series when the result is 1-dimensional data. ![]() Note that the above 2 outputs are Series. loc Weather Shower Temperature 10.51 Wind 26 Humidity 79 Name: Fri, dtype: object # The equivalent `iloc` statement > df. ilocĪnd to get all columns: # To get all columns > df. For example, to get all rows: # To get all rows > df.loc Day Mon 12.79 Tue 19.67 Wed 17.51 Thu 14.44 Fri 10.51 Sat 11.07 Sun 17.50 Name: Temperature, dtype: float64 # The equivalent `iloc` statement > df. ![]() The equivalent iloc statement should take the row number 4 and the column number 1. With loc, we can pass the row label 'Fri' and the column label 'Temperature'. We can use the following syntax for data selection:įor example, let’s say we would like to retrieve Friday’s temperature value. Selecting via a single valueīoth loc and iloc allow input to be a single value.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |