i was trying to find out the solution by myself but unfortunately couldn't succeed.
-> i have a scientific dataset with 12 columns representing 4 different monitoring stations and each station measures 3 different kind of pollutants. the data contains around 70000 chronological timestamps (rows). since 2 out of the 3 pollutants are given in a different unconvenient unit i have to multiply those columns by a certain value (i.e. have to manipulate 8 columns)
how can i do that so i get the dataframe arranged in the same way but with the manipulated columns integrated?
thank you in advance for any help provided!
Let's start with a simplified version of your problem.
Imagine I have a dataframe of temperatures for various cities over time. However, for some of those cities, I have the temperatures in Celsius, and I need to convert those columns to Fahrenheit. Other cities are already in Fahrenheit.
Here's the example dataset:
And here it is in code form:
In this example, I want to convert the values for Denver, Arvada, and Aurora from Celsius into Fahrenheit, then save that back into the same dataframe. For every temperature value in those columns, I need to multiply by 1.8, and add 32.
Fortunately, Pandas makes it easy to manipulate an entire column. Converting Denver to Fahrenheit looks like this:
In Pandas, multiplying a column by a scalar (i.e. single value) means that you multiply each element by that scalar.
Then, I can do the same thing for Aurora and Arvada. Normally, I would use a loop, to avoid writing the same piece of code three times.
However, since you only have eight columns, and since you're multiplying by a different value each time, a loop might not be helpful for you.