f# - unpivot a deedle dataframe -
the stack function of frame can turn info frame this
cola colb colc 1 -> 10 <missing> aaa 3 -> 20 5.5 bb 5 -> 30 <missing> <missing> 6 -> 40 <missing> ccc
into
row column value 0 -> 1 cola 10 1 -> 1 colc aaa 2 -> 3 cola 20 3 -> 3 colb 5.5 4 -> 3 colc bb 5 -> 5 cola 30 6 -> 6 cola 40 7 -> 6 colc ccc
however needed utilize 1 of column value , other column's heading bring together key new column while doing unpivot. how can accomplish result like:
0 -> 10 colb <missing> 1 -> 10 colc aaa 2 -> 20 colb 5.5 3 -> 20 colc bb 4 -> 30 colb <missing> 5 -> 30 colc <missing> 6 -> 40 colb <missing> 7 -> 40 colc ccc
the original cola's value , column headings colb , colc have become combined key point colb value , colc value.
how can accomplish deedle?
i don't think have built-in function automatically in deedle, can iterating on rows of frame , iterating on columns:
assuming f
sample input frame question, next should trick:
[ r in f.rows.values c in r.keys if c <> "cola" yield r.get("cola"), c, r.tryget(c) ] |> frame.ofrecords
f# unpivot deedle
No comments:
Post a Comment