I have 2 datasets, a list r
and a dataframe df
.
r = [1,1,1,1,1,1,1,1,2,2,2,2,2,1]
df
|----|----|----|----|----|----|----|----|----|----|
| d1 | d2 | d3 | d4 | d5 | d6 | d7 | d8 | d9 | d10|
|----|----|----|----|----|----|----|----|----|----|
| 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 |
| 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 | 1 | 1 |
I am trying to run an if
statement that evaluates the selection of a random value from df
vs r
. However I get an error.
The post in this link kind of exposes the problem and I did tried the methods but doesn't seem to be working.
I tried to used the methods proposed in the link above and in the error (.any()
, .all()
, .bool()
) but don't see to get it working.
df1 = df.sample(n=1)
if(df1 <= r):
df
r-=df
Aucun commentaire:
Enregistrer un commentaire