nested list comprehension with args 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: list comprehension
# List comprehension
list_comp = [i+3 for i in range(20)]
# above code is similar to
for i in range(20):
print(i + 3)