|
|
|
|
|
by farnsworth
3305 days ago
|
|
But pandas’ magical simplicity makes things like computed columns immediately intuitive:
> data['% of total'] = data.amount / data.amount.sum()
Is that immediately intuitive? I'm staring at this trying to understand what it's doing. Is the / operator overloaded? data.amount is one particular amount, and data.amount.sum() is the sum of all amounts? Why does the "computed column" property goes on the same data object as the actual data? Maybe it's immediately intuitive if you've used pandas. |
|
When you see amount / sum, you think of how a list can be divided by what appears to a scalar.
When they see it, they parse it out for what they naturally understand a percentage to mean. And all is well.