Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何迭代数据帧中的每一行_Python_Jupyter Notebook - Fatal编程技术网

Python 如何迭代数据帧中的每一行

Python 如何迭代数据帧中的每一行,python,jupyter-notebook,Python,Jupyter Notebook,我有一个数据框,里面有关于摔跤比赛的各种信息。我在标题上对数据框进行了分组,因为我只需要标题、性别和持续时间。数据帧是32行 我已宣布资料如下 title = df['Title'] duration = df['Duration'] gender = df['Gender'] 并使用for循环 for x in df.index: print("test") 正如我预期的那样,它测试了32次 但为什么当我试着 print(test+gender) if打印32行32次,就像它执行for循

我有一个数据框,里面有关于摔跤比赛的各种信息。我在标题上对数据框进行了分组,因为我只需要标题、性别和持续时间。数据帧是32行

我已宣布资料如下

title = df['Title']
duration = df['Duration']
gender = df['Gender']
并使用for循环

for x in df.index:
print("test")
正如我预期的那样,它测试了32次

但为什么当我试着

print(test+gender)
if打印32行32次,就像它执行for循环32次一样

如何让for循环只发生一次?

您应该执行以下操作:

for x in df.index:
    print(gender[x])
如果没有[x]部分,性别是由32行组成的系列