How do I change rows and columns in a dask dataframe?

前端 未结 1 501
一生所求
一生所求 2020-12-20 15:24

There are few issues I am having with Dask Dataframes.

lets say I have a dataframe with 2 columns [\'a\',\'b\']

if i want a new column c =

相关标签:
1条回答
  • 2020-12-20 15:43

    Edit Add New Columns

    Setitem syntax now works in dask.dataframe

    df['z'] = df.x + df.y
    

    Old answer: Add new columns

    You're correct that the setitem syntax doesn't work in dask.dataframe.

    df['c'] = ... # mutation not supported
    

    As you suggest you should instead use .assign(...).

    df = df.assign(c=df.a + df.b)
    

    In your example you have an unnecessary call to .compute(). Generally you want to call compute only at the very end, once you have your final result.

    Change rows

    As before, dask.dataframe does not support changing rows in place. Inplace operations are difficult to reason about in parallel codes. At the moment dask.dataframe has no nice alternative operation in this case. I've raised issue #653 for conversation on this topic.

    0 讨论(0)
提交回复
热议问题