I am practicing working in dataframe in pandas.i came across an error for which i dont understand the reason why there is an error.Can some one explain me the reason.
Note:
This only occurs when i use df.iloc[i+1,0] line of code. if i only use df.iloc[i,0] it works fine
Dataframe:
A,B
1,2
2,3
4,5
5,6
6,7
7,8
9,10
Code:
import pandas as pd
df = pd.read_csv("text.txt")
for i in range(0,len(df)):
if (df.iloc[i,0] + df.iloc[i+1,0]) == 5 :
print("hey")
Error: single positional indexer is out-of-bounds
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…