list comprehension python if on data frame column code example
Example: pandas list comprehension
# Subtract 1 from row, for each row in df.year
df['previous_year'] = [row-1 for row in df['year']]
# Subtract 1 from row, for each row in df.year
df['previous_year'] = [row-1 for row in df['year']]