Probably a rookie question, but I'm new to Python and Pandas and still learning the syntax. I'm developing a script where I'd like to structure a conditional that multiplies a cell value over an entire column.
Here's the structure of the test.csv:
I'd like to create a column error_count_score that multiplies the value in the error_count cell by 3 if it is greater than 3 (as an Excel formula, it would be: =IF(C2<=3,0,(C2*3)) ). The values for the new column in this case would be 0 and 12.
I suspect there are multiple ways to solve this, but I'm uncertain how to structure the code. Here's my working code attempt:
import pandas as pd
df = pd.read_csv("test.csv")
df.loc[df['error_count'] >= 3, 'error_count_score'] = #do I put an object here? * 3
Any assistance or advice greatly appreciated.
