[Pandas-dev] Chained filtering with lazy evaluation ("where")

Pietro Battiston ml at pietrobattiston.it
Thu Mar 15 14:24:12 EDT 2018


Il giorno gio, 15/03/2018 alle 12.58 -0500, Tom Augspurger ha scritto:
> FYI, `df.loc[lambda x: x['a'] > 3]` is valid. loc takes a callable,
> and evaluates it with the NDFrame as the first (only) argument.

Aha! I knew one could pass callables, but I had mistakenly assumed the
mechanism was analogous to df.apply(), i.e. accepting rows/elements
rather than the NDFrame itself.

I think I like my solution better... but for sure adding it to pandas
would duplicate an already present functionality.

Thanks (to you and Chris) for the pointer,

Pietro


More information about the Pandas-dev mailing list