小编Xou*_*oul的帖子

使用 iterrows() 时如何通过索引访问列

我想知道在iterrows用于遍历 DataFrame时如何使用索引而不是名称访问列。

这段代码是我能找到的最多的:

for index, row in df.iterrows():
    print row['Date']
Run Code Online (Sandbox Code Playgroud)

这是我用来遍历的另一种方法,但它似乎很慢:

for i in df.index:
    for j in range(len(df.columns)):       
                    df.ix[i,j] = 0
Run Code Online (Sandbox Code Playgroud)

python python-2.7 pandas

3
推荐指数
1
解决办法
7179
查看次数

标签 统计

pandas ×1

python ×1

python-2.7 ×1