I'm trying to write a for loop in python that compares each ith element in one array px
to the ith element in another array py
. If the element in px
is greater than or equal to that of py
than I want to note that value as True
or 1.
Here's some code.
import pandas as pd
import random
px = np.random.normal(loc=0, scale=1, size=1000)
py = np.random.normal(loc=0, scale=1, size=1000)
for x, y in zip(px, py):
print("{}% {}".format(x, y))
if px[i] >= py[i]:
px['status'] = True
if px[i] < py[i]:
px['status'] = False
The final dataframe should look something like this:
px py status
-2.24239571e-01 -1.83834445e+00 False
1.20102447e+00 5.01755172e-03 False
8.82060986e-02 -2.55639665e-02 True
I know I have some problems with my for loop.
Aucun commentaire:
Enregistrer un commentaire