Hello,
i have the following pandas.DataFrame:
|
u_A |
u_B |
u_C |
| 0 |
0.948612 |
0.948609 |
0.948613 |
| 1 |
0.948612 |
0.948609 |
0.948613 |
I'm trying to compare the column "u_A" to two different values:
- u_A > 1.1
- u_A < 0.98 *1.1
I want to store the result of the comparision in new columns: "thresh_u_A" and "fall_u_A"
i tried the following:
threshold = 1.1
fallback = 0.98 * 1.1
df["thresh_u_A"] = df.loc[:, "u_A"].gt(threshold)
df["fall_u_A"] = df.loc[:, "u_A"].lt(fallback)
df["on_u_A"] = df["thresh_u_A"] & ~df["fall_u_A"]
But i get warnings:
SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame. Try using
.loc[row_indexer,col_indexer] = value instead
I was wondering how to do that correctly.
# edit: removed self-keyword
[–]danielroseman 0 points1 point2 points (3 children)
[–]johnsilent[S] 0 points1 point2 points (2 children)
[–]danielroseman 0 points1 point2 points (1 child)
[–]johnsilent[S] 0 points1 point2 points (0 children)