AI engineering glossary · NumPy pandas visualization
What is shift?
shift (also called lag, diff): A pandas method that moves values up or down by a number of rows while keeping the index fixed, leaving NaN at the empty end. It is used to compare a row with a previous one or to create lag features for forecasting.
shift: an example
df['prev_day'] = df['price'].shift(1) puts yesterday's price next to today's price in each row.
Related terms
More NumPy pandas visualization terms
Where you learn it
shift is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.