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

Pietro Battiston ml at pietrobattiston.it
Thu Mar 22 10:35:31 EDT 2018


Il giorno gio, 15/03/2018 alle 15.10 -0400, Justin Lewis ha scritto:
> I might be missing the point but can you use .pipe()?

Indeed, this is something else I had not considered.

However I don't like it to much. Compare

.loc[W]

with

.pipe(lambda df : df[df])

By the way,

.loc[lambda df : df[df]]

is equivalent but cleaner to me (after all, we are selecting).

This said, the solutions proposed by you and Chris are indeed more
robust then mine. For instance,

.loc[W + 1 > 2]

works but 

.loc[2 < 1 + W]

doesn't, and I don't even know if a fix is possible.

Pietro


More information about the Pandas-dev mailing list