ylxw
V2EX  ›  问与答

pyspark dataframe array 列求和

  •  
  •   ylxw · Oct 12, 2018 · 3732 views
    This topic created in 2790 days ago, the information mentioned may be changed or developed.
    pyspark dataframe 中其中一列的数据类型为 ArrayType(IntegerType()),如何对这列求和

    如:
    +----------------+
    | x|
    +----------------+
    |[[1, 5], [1, 5]]|
    |[[0, 1], [0, 1]]|
    |[[4, 5], [4, 5]]|
    +----------------+
    如何将求 x 列的总和,得到[[5,11],[5,11]]
    1 replies    2018-10-16 10:44:59 +08:00
    ylxw
        1
    ylxw  
    OP
       Oct 16, 2018
    装换为 rdd,使用累加器进行求和
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1240 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 17:47 · PVG 01:47 · LAX 10:47 · JFK 13:47
    ♥ Do have faith in what you're doing.