pandas :遍历各列并从一列开始 [英] Pandas: Iterate through columns and starting at one column

查看:64
本文介绍了 pandas :遍历各列并从一列开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何为列合并forloop但要从任何列开始吗? (这种情况下的第三个)

Does anyone know how to incorporate a forloop for columns but start at any column? (The third one for this scenario)

让我们说这是数据帧:

spice smice skice bike dike mike 
1     23     35    34   34   56 
135   34     23    21   56   34
231   12     67    21   62   75

我想仅

I want to iterate through skice, bike, dike, and mike only

推荐答案

由于df.columns为您提供了列列表,因此您可以在下面进行操作并从第3列名称进行迭代.

Since df.columns provides you the list of columns, you can do below and iterate from 3rd column name.

for col in df.columns[2:]:
    #print(df[col].unique())

这篇关于 pandas :遍历各列并从一列开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆