遍历行和列列表

时间:2019-07-10 16:45:09

标签: python

我希望翻转我的数据集以将其移至模型中,并且在循环遍历列和行以总结体积时遇到问题。下面的例子

这在Spark中,所以语法对我来说是个问题

n=3
df = sql('select * from Volume_Master')
brandvar = df.select('brand').distinct()
columnvar = df.columns.tolist()
columnvar2 = columnvar[n:]

目前的样子

Store   cd      brand   vol_L13w    vol_L26w    vol_YAG_13w
634757  1         1        10          20            10
634757  1         2        20          25            20
634757  1         3        30          25            30
634757  1         4        40          25            40

我的目标

Store   custom_category_cd  Brand1_vol_L13w Brand1_vol_L26w Brand1vol_YAG_L13w
634757  1   10  20  10  20  25  20  30  25  30  40  25  40

0 个答案:

没有答案
相关问题