gpt4 book ai didi

dataframe - 如何在 FSI 中将 Deedle DataFrame 显示为漂亮的表格?

转载 作者:行者123 更新时间:2023-12-04 23:13:20 25 4
gpt4 key购买 nike

阅读文章 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 ) 我认为(可能是错误的)可以显示 Deedle DataFrame 的内容在 FSharp Interactive ( FSI ) 作为一张漂亮的 table 。

让我这么想的文本片段如下:

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 的内容。 .

无需安装和打开 FSLab ,正如文章中所推荐的,当我可以创建一个 DataFrameFSI然后输入它的名字和“;;”我得到这样的东西:
> 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

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

所以,

1) 我真的可以得到一个很好的表格来显示 Deedle DataFrame 的内容吗?在 FSI (就像一个人所做的那样,例如,在 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 引用 Deedle 并运行上面的代码,你会得到很好的打印输出。或者,您也可以通过显式调用来获得相同的输出:
df.Print()

关于dataframe - 如何在 FSI 中将 Deedle DataFrame 显示为漂亮的表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49575984/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com