Loading tutorials
shift() example in this tutorial uses a Series or DataFrame whose index is a DatetimeIndex. This chapter covers how to build that index, which properties of it matter for shifting, and how to check it before you lag anything. It also defines the small sales Series that later chapters reuse7 min readshift() on a time series: what it moves, what it leaves alone, and how to check that a lag is correct. It assumes you know basic Python, can create and index pandas Series and DataFrames, and are comfortable with DatetimeIndex and pd.date_range. Leads, 6 min readDatetimeIndex and pd.date_range. It also assumes you have seen shift(1) produce a lag. Here you will use the other direction: a negative periods value, which produces a lea6 min readpd.date_range, index it by date, and call shift(1) on it. You should also know the basic NaN tools: isna(), fillna() and dropna(). The chapter explains where the missing values from shift() come from, what they do to your data types, and7 min readDatetimeIndex, that you know what shift(1) and shift(-1) do, and that you know why shift() leaves NaN at one edge. Here you will use that knowledge to measure change from one period to the next. You will also see where the shortcuts `diff6 min readSeries with a DatetimeIndex, you know pd.date_range, and you have already used shift(1) to build a lag. Here you will learn the second way shift() works, the freq argument, and when to use it instead of a positional shift.7 min readDatetimeIndex and pd.date_range work. It also assumes you have seen shift(periods) as a positional lag. If you haven't, read the earlier chapters on shift() first.7 min readshift() treats the whole column as one series, so it mixes the groups. This chapter shows how to lag each group separately with `grou6 min readshift() is the main tool for preventing it, and a wrong sign or a missing shift() is the main way to cause it. This chapter covers where leakage comes from, ho7 min readshift() fixes that, how to choose the wi5 min read