Calculate a whole column at once
Pandas arithmetic operates on every row of a Series. Use .assign(new_name=expression) to return a DataFrame with a derived column while keeping the source columns.
| index | duration_ms |
|---|---|
| 0 | 125 |
| 1 | 500 |
| 2 | 1200 |
| index | duration_ms | duration_seconds |
|---|---|---|
| 0 | 125 | 0.125 |
| 1 | 500 | 0.5 |
| 2 | 1200 | 1.2 |