NoIdeaHowToFixThis
NoIdeaHowToFixThis

Reputation: 4574

Deedle - create empty list and series

I am new to F#, looking at it as an alternative to Matlab.

In reference to this question, how can I create an empty Serie and an empty Frame. If I did not just miss it, why an empty Serie or Frame has not been designed in the library, something like list.empty ?

Upvotes: 4

Views: 833

Answers (1)

Tomas Petricek
Tomas Petricek

Reputation: 243106

Adding Frame.empty and Series.empty is a great suggestion. I think these should be in the library and I'm adding an issue to GitHub to make sure they get added.

In the meantime, you should be able to use something like this:

let empty : Series<int, float> = series []
let empty : Frame<int, string> = frame []

Note that I had to add type annotations - from my code snippet, the compiler cannot figure out what is the type of keys and values, so I had to explicitly specify that (but if you use the values as arguments to other functions, then this should not be needed).

The second line does not actually work in the current version, because of a bug (oops!) so you can use Frame.ofRows instead, which works fine:

let frame : Frame<int, string> = Frame.ofRows []

EDIT: The bug is now fixed in version 0.9.11-beta

Upvotes: 5

Related Questions