import pandas as pd
# 创建一个示例DataFrame
data = {
'A': [1, 2, 3],
'B': [4, 5, 6]
}
df = pd.DataFrame(data)
# 使用.iterrows()逐行遍历DataFrame
for index, row in df.iterrows():
print(f"Index: {index}")
print(f"Row Data:\nA = {row['A']}\nB = {row['B']}\n")