Skip to content
Advertisement

Python: Pandas Dataframe how to multiply entire column with a scalar

How do I multiply each element of a given column of my dataframe with a scalar? (I have tried looking on SO, but cannot seem to find the right solution)

Doing something like:

JavaScript

gives me a warning:

JavaScript

Note: If possible, I do not want to be iterating over the dataframe and do something like this…as I think any standard math operation on an entire column should be possible w/o having to write a loop:

JavaScript

EDIT:

I am running 0.16.2 of Pandas

full trace:

JavaScript

Advertisement

Answer

Here’s the answer after a bit of research:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement