Calmcode - pandas pipe: new

Larger Pipeline Steps in Pandas

1 2 3 4 5 6 7 8 9

You can add this step to the pipeline to get inflation numbers.

def add_inflation_features(dataf):
    return (dataf
            .assign(local_inflation=lambda d: d.groupby('name')['local_price'].diff()/d['local_price'])
            .assign(dollar_inflation=lambda d: d.groupby('name')['dollar_price'].diff()/d['dollar_price']))

clean_df = (df
  .pipe(remove_outliers, min_row_country=20)

Remember that it is relatively easy to make a new function, as long as you make a temporary variable to save the current dataframe into.