i need do read the rows of a dataframe but it seems to stop at the first row. I also tried with iterrows but the results are similar.
JavaScript
x
29
29
1
for i in range(1, 100):
2
#for i, r in d.iterrows():
3
if self.total_count >= 100:
4
done = True
5
else :
6
done = False
7
self.total_count += 1
8
h = d.loc[i]
9
print(h)
10
if action == 0:
11
for index, row in df.iterrows():
12
if h['id'] == row['id']:
13
reward = 1
14
print("Equals")
15
16
else:
17
reward = 0
18
self.miss_count += 1
19
20
elif action == 1:
21
num = random.randrange(1, len(df), 1)
22
df = df.drop(df.index[[num]])
23
df = df.append(h, ignore_index=True)
24
reward = 0
25
print(df)
26
info = {}
27
#M = self.df['id'].to_numpy()
28
return df, reward, done, info
29
and the outpus is :
JavaScript
1
9
1
id 4z_3v0atqk0
2
size 131
3
Name: 1, dtype: object
4
Equals
5
id 4z_3v0atqk0
6
size 131
7
Name: 1, dtype: object
8
Equals
9
so the for doesn’t iterate. I hope someone can help me, thank you so much.
Advertisement
Answer
You are performing
JavaScript
1
2
1
return df, reward, done, info
2
inside the loop.
This breaks the loop on the very first iteration