2

How can I achieve this in Deedle.

Pandas: df['Name'] = 'abc'

Deedle: df?Name = "abc" doesn't work - it expects a series.

Anil
  • 1,079
  • 1
  • 13
  • 23

1 Answers1

4

Given a sample data frame with one column:

let df = 
  frame [ "One" => series [ 1 => 1.1; 2 => 2.2 ] ]

To add a new column, you will need to create a series with values for all rows first. Then you can add it to the frame in very similar way to pandas:

df?Two <- series [ for k in df.RowKeys -> k => "abc" ]
Tomas Petricek
  • 240,744
  • 19
  • 378
  • 553
  • 2
    Would it be possible to have something like `Frame.addColWith` where one could pass a column name and a function `key -> value` used to produce new value by key? Then I could to this: `Frame.addColWith "Name" (fun k -> "abc")` – Anil May 25 '17 at 16:56
  • 2
    @Anil Absolutely. You can define this function and have it in some common Deedle extensions module in your project, or write a few tests & docs for it and send a PR to Deedle :-) – Tomas Petricek May 25 '17 at 22:02