0

Is there a more efficient way to reorder columns in a Deedle frame than doing something like the following:

let fr2 = fr.Columns.[["colC"; "colA"; "colB"]]

It seems a bit inefficient, especially given that I have to iterate through a ton of these files every weekend. There is a related question here but doesn't seem to work for me.

Community
  • 1
  • 1
  • Can you be more specific in what you are trying to achieve (ie. why the above two methods don't work for you), that should narrow down a solution. Some of the functions that spring to mind are `getCols, addCol, dropCol, replaceCol`. – s952163 Aug 02 '16 at 01:37
  • 1
    i) Why does a new object have to be created simply to reorder columns when a better way would be to simply mutate the existing object? ii) The question that is linked refers to methods that apparently do not exist. i.e. Frame.FromColumns ? – professor bigglesworth Aug 02 '16 at 01:55
  • Thanks. I think if it's better to mutate or return another object is one of the great schisms of programming. I can see if you have a lot of data frames how that could pressure the GC maybe. Not sure on the implementations details there. Let me wade into the Deedle API to see what would fit best. – s952163 Aug 02 '16 at 02:02

1 Answers1

1

How about this:

let df = Frame.ofColumns(df.Columns.Realign(newcolidx))

As this appears to me returning a new df, it might not be ideal for you.

And this Issue still remains open.

s952163
  • 6,276
  • 4
  • 23
  • 47