1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to assign column values based on another column iteratively with Polars

Discussão em 'Python' iniciado por Stack, Setembro 15, 2024.

  1. Stack

    Stack Membro Participativo

    For these two dfs, I want to check for each i in df1["TS"] if df["TS"] == df1["TS}, then assign the value in "Dr" that corresponds to i to the "mmsi" column:

    df = pl.DataFrame({"TS": [1, 2, 3, 4, 5, 6, 7], "mmsi":[11,12,13,14,15,16,17]})


    df1 = pl.DataFrame({
    "TS": [4, 6, 7],
    "Dr": [21,22,23]})


    I want the output of df["mmsi"] to be: [11,12,13,21,15,22,23]

    Continue reading...

Compartilhe esta Página