Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- """
- data=
- Date High Low failure
- 0 12/01 90 60 0
- 1 12/03 88 61 0
- 2 12/05 76 38 15
- 3 12/07 70 36 17
- 4 12/09 81 56 2
- """
- def tail_min(df):
- return df.tail(2).min()
- def tail_max(df):
- return df.tail(2).max()
- indexer = pd.api.indexers.FixedForwardWindowIndexer(window_size=3)
- data["rolling_High"] = data["High"].rolling(window = indexer, min_periods=1).apply(tail_max)
- data["rolling_Low"] = data["Low"].rolling(window = indexer, min_periods=1).apply(tail_min)
- #failure > 10 and next 2 columns max and min
- data.loc[data["failure"] > 10, ["failure","rolling_High", "rolling_Low"]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement