pandas dataframe list comprehension code example
Example 1: pandas list comprehension
# Subtract 1 from row, for each row in df.year
df['previous_year'] = [row-1 for row in df['year']]
Example 2: comprehension list iloc pandas
df['Flag'] = ["High Bracket" if x > 70 else "Low Bracket" for x in df['prevsalary']]