fslaborg / Deedle

Easy to use .NET library for data and time series manipulation and for scientific programming
http://fslab.org/Deedle/
BSD 2-Clause "Simplified" License
924 stars 197 forks source link

Dataframe Add/Change column accroding the function. #447

Open alexpantyukhin opened 5 years ago

alexpantyukhin commented 5 years ago

Maybe this feature already exists, but I couldn't find it. I guess it would be useful to have something like this:

  let df = 
    frame [ "A" => series [ 1 => 1.0; 2 => 2.0 ]
            "B" => series [ 1 => 4.0; 2 => 5.0 ] ]
  let df' = df.SetColumn("C", fun row -> row["A"] + row["B"])

In pandas it's possible with function apply. For example:

   filtred['gender_num'] = filtred['gender'].apply(lambda x: 1 if x == 'male' else 0)