3

I imported some data in a Deedle Frame, and I'm trying to convert values type in integer type.

I used the following code:

let myFrmK01 = Frame.ReadCsv(@"QuandlDataSample.csv", hasHeaders=true)
let myFrmK02 = myFrmK01
                |> Frame.indexRowsDate "Date"
                |> Frame.sortRowsByKey

Now, to convert the values type I tryed with:

let myFrame03 = Frame.mapValues (fun (x:float) -> (Convert.ToUInt64(x * 100.0))) myFrame02

and if I go to see the values of the frame with:

myFrame03.Item("Adj. Open").Item (DateTime(2017, 5, 3))

I find it is still a float. Where I'm wrong?

Thanks.

Felice Bruno
  • 195
  • 1
  • 12

1 Answers1

5

You are wrong in taking result of Frame.Item property for the genuine type of the column. The signature of myFrame03.Item("Adj. Open") is string -> Series<DateTime,float>, so the result of individual observation cannot be anything, but float.

If you use another form of Item property

myFrame03.Item("Adj. Open",DateTime(2017, 5, 3))

having the signature string*DateTime -> obj you must see that the observation is unsigned long as expected after you've applied Frame.mapValues, indeed.

Besides, when in doubt, you can always check actual data frame column types:

myFrame03.ColumnTypes |> Seq.iter (printfn "%A")
Gene Belitski
  • 10,270
  • 1
  • 34
  • 54