如何在FSI中显示为deedle dataframe作为漂亮的表格



阅读文章 Analyzing and Visualizing Data with F#(https://www.oreilly.com/ideas/analyzing-and-data-data-with-with-fith-f-sharp/page/page/2/analyzing-data--data--我收集的(也许是错误的(使用F-and-weedle(可以将Deedle DataFrame的内容显示为FSharp Interactive(FSI(中的内容。

让我认为的文字片段如下:

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.

这些行之前是一张漂亮的表,显示了DataFrame的内容。

在文章中建议的情况下,我可以在FSI中创建DataFrame,然后输入其名称和" ;;",而无需安装和打开FSLab。我得到这样的东西:

> 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]];}

因此,我尝试安装FSLab,但它似乎与以前安装的软件包版本具有不兼容。安装无法完成,我会收到以下消息:

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   

我怀疑这个问题有一个简单的解决方案。

so,

1(真的,我可以在FSI中获得一个不错的表显示Deedle DataFrame的内容(例如,在RStudio中,R中的内容(?

2(如果是,我该怎么做才能能够可视化此类表,而无需向后移动我已安装的包装版本?

如果您使用包含的Deedle.fsx加载脚本引用deedle,则会自动注册F#Interactive的打印机:

#load "packages/Deedle/Deedle.fsx"
open Deedle
let df = 
  [ "First" => Series.ofValues [1;2;3;4]
    "Second" => Series.ofValues [1;2;3;4] ]
  |> frame

如果您使用paket引用契约并运行上述代码,则将获得不错的打印输出。另外,您也可以通过明确调用来获得相同的输出:

df.Print()

相关内容

  • 没有找到相关文章

最新更新