02
Monotonicity¶
Decreasing¶
df["Reading"] = (
df
.sort_values("Time_Point", ascending=True) # this is the time column, so always ascending
.groupby("Temperature")
["Reading"]
.cummin()
)
# or
df_train["Reading_Time_Point_Cummin"] = (
df_train
.sort_values("Time_Point", ascending=True) # this is the time column, so always ascending
.groupby("Temperature")
["Reading"]
.cummin()
)
df_train = df_train.query("Reading <= Reading_Time_Point_Cummin")
Increasing¶
df["Reading"] = (
df
.sort_values("Time_Point", ascending=True) # this is the time column, so always ascending
.groupby("Temperature")
["Reading"]
.cummax()
)
df_train["Reading_Time_Point_Cummax"] = (
df_train
.sort_values("Time_Point", ascending=True) # this is the time column, so always ascending
.groupby("Temperature")
["Reading"]
.cummax()
)
df_train = df_train.query("Reading >= Reading_Time_Point_Cummin")
Sampling¶
# if n=frac, then percentage of dataset
df.sample(
0.10
)
# if n=int, then count of dataset
df.sample(
1_000
)
# sampling with prob weights
df.sample(
1_000,
weights = "Weight_Column"
)
Multi-Index¶
ObjectName¶
2024-05-14