I'm very new to Pandas and I've been trying to build an if-stetament function to apply in a dataframe column.
I need a function to look for each row in the column 'type of inflow' and then depend on the kind of the letter assign a positive or negative number on a new column called 'cash flow'.
df = {'type of inflow':['I', 'D', 'I', 'D', 'R', 'D'], 'historic value':[100, 300, 200, 700, 400, 600]}
def cash_flow(row):
if row['type of inflow'] == "I" or row['type of inflow'] == "D":
row['type of inflow'] = row['historic value'] * -1
elif row['type of inflow'] == "R":
row['cash flow'] = row['historic value'] * 1
Thanks in advance