I am trying to figure out how to use a Locindexer object to select a subset of a dataframe.
For example
var = df.loc(df['rating'] == 4)
Returns as
pandas.core.indexing._LocIndexer
How do I use a LocIndexer to select the a subset of my dataframe?
You are calling it as a function. For indexing, you use [].
df.loc[df['rating'] == 4]
would return the row/rows in which value of column rating is 4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With