Mar-04-2021, 05:23 PM
you miss
def
. then there is problem how you access the column.import pandas as pd def apply_power_sq(df, column): df[column] = df[column].pow(2) df = pd.DataFrame({'spam': [0, 3, 4], 'eggs': [1, 2, 3]}) print(df) apply_power_sq(df, 'spam') print(df)
Output: spam eggs
0 0 1
1 3 2
2 4 3
spam eggs
0 0 1
1 9 2
2 16 3
Now, what is the purpose of value that you want to pass?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs