Comment

Comment by ryan-duve

I wonder if the author would have thought Pandas feels less clunky if they knew about `.eval`?

    import pandas as pd


    purchases = pd.read_csv("purchases.csv")

    (
        purchases.loc[
            lambda x: x["amount"] < 10 * x.groupby("country")["amount"].transform("median")
        ]
        .eval("total=amount-discount")
        .groupby("country")["total"]
        .sum()
    )
parent ryan-duve 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton