3 ms·
.loc lets you supply a callable, so you can write: table.loc[lambda df: df["column"].between(2, 3, inclusive="neither")] this is useful when your dataframe
by _dain_ 5y ago
.loc lets you supply a callable, so you can write:
table.loc[lambda df: df["column"].between(2, 3, inclusive="neither")]
this is useful when your dataframe has a long name, or when you have some long method chain and you need to subset at the end: table.foo().bar().baz().loc[lambda df: ...]
it is still more verbose, but I actually prefer always providing column names as strings. it's more explicit. I don't like R's environment-manipulation metaprogramming magic where you can give column names as symbols.
as for resetting the index all the time, this is something of an antipattern. if you set up your index right beforehand it isn't necessary so often.