Reading the article Analyzing and Visualizing Data with F#
(https://www.oreilly.com/ideas/analyzing-and-visualizing-data-with-f-sharp/page/2/analyzing-data-using-f-and-deedle) I gathered (perhaps incorrectly) that one could display the contents of a Deedle DataFrame
in FSharp Interactive
(FSI
) as a nice table.
The text fragment that made me think so is the following:
When you create a data frame, F# Interactive formats it nicely so you can get a quick idea about the data. For example, in Table 2-1 you can see the ranges of the values and which values are frequently missing.
These lines were preceded by a nice table showing the contents of a DataFrame
.
Without installing and opening FSLab
, as recommended in the article, when I can create a DataFrame
in FSI
and then enter its name and ";;" I get something like this:
> df;;
val it : Frame<int,string> =
Deedle.Frame`2[System.Int32,System.String]
{ColumnCount = 2;
ColumnIndex = Deedle.Indices.Linear.LinearIndex`1[System.String];
ColumnKeys = seq ["A"; "B"];
ColumnTypes = seq [System.Int32; System.Int32];
Columns = series [ A => series [ 0 => 1; 1 => 2; 2 => 3; 3 => 4; 4 => 5; ... ; 9 => 10]; B => series [ 0 => 11; 1 => 12; 2 => 13; 3 => 14; 4 => 15; ... ; 9 => 20]];
ColumnsDense = series [ A => series [ 0 => 1; 1 => 2; 2 => 3; 3 => 4; 4 => 5; ... ; 9 => 10]; B => series [ 0 => 11; 1 => 12; 2 => 13; 3 => 14; 4 => 15; ... ; 9 => 20]];
IsEmpty = false;
Item = ?;
Item = ?;
RowCount = 10;
RowIndex = Deedle.Indices.Linear.LinearIndex`1[System.Int32];
RowKeys = seq [0; 1; 2; 3; ...];
Rows = series [ 0 => series [ A => 1; B => 11]; 1 => series [ A => 2; B => 12]; 2 => series [ A => 3; B => 13]; 3 => series [ A => 4; B => 14]; 4 => series [ A => 5; B => 15]; ... ; 9 => series [ A => 10; B => 20]];
RowsDense = series [ 0 => series [ A => 1; B => 11]; 1 => series [ A => 2; B => 12]; 2 => series [ A => 3; B => 13]; 3 => series [ A => 4; B => 14]; 4 => series [ A => 5; B => 15]; ... ; 9 => series [ A => 10; B => 20]];}
So I tried to install FSLab
, but it seems to have incompatibilities with versions of packages I have previously installed. Installation does not go through and I get the following message:
Severity Code Description Project File Line Suppression State
Error Unable to resolve dependencies. 'FSharp.Data 2.4.6' is not compatible with 'FsLab 1.0.2 constraint: FSharp.Data (= 2.3.2)'. 0
I suspect there is a simple solution to this problem.
So,
1) Is it true that I can get a nice table displaying the contents of a Deedle DataFrame
in FSI
(much as one does, for example, in RStudio
for R
)?
2) If yes, what should I do to be able to visualize such tables without moving backwards the versions of packages I have installed?
The printers for F# Interactive are registered automatically if you reference Deedle using the Deedle.fsx
load script that is included in the package:
#load "packages/Deedle/Deedle.fsx"
open Deedle
let df =
[ "First" => Series.ofValues [1;2;3;4]
"Second" => Series.ofValues [1;2;3;4] ]
|> frame
If you reference Deedle using Paket and run the above code, you get nice print-out. Alternatively, you can also get the same output by explicitly calling:
df.Print()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With