Deedle C#(開発者向けの動作方法)
Deedle C#
Deedle はデータ操作およびデータ分析のための強力なライブラリです。 これは全体のデータフレームやシリーズを提供し、構造化されたデータフレームを効率的に処理することができます。 Deedle は ofNullables および ofObservations という静的メンバーを使用して欠落データの処理、データの整列、補助関数の適用のためのツールを提供しています。 これはデータサイエンスでその柔軟性と性能のために広く使用されています。
IronPDF は .NET で PDF ドキュメントを作成および操作するためのライブラリです。 これは HTML から PDF を生成し、画像を PDF に変換し、PDF ファイルからコンテンツを抽出するのに役立ちます。 IronPDF は .NET プロジェクトの PDF タスクを簡単にします。
この記事では、C# 用の Deedle の始め方、Visual Studio を使用して .NET プロジェクトにセットアップする方法、および自動生成されたドキュメントを使用して主要な機能を実装する方法を学びます。 Deedle を効果的に使用するためのコード例と説明を見て、指定された関数を適用する方法を理解します。
Deedle C# を始める
.NET プロジェクトでの Deedle の設定
始めに、Visual Studio で新しい C# コンソールアプリケーションプロジェクトを作成します。
.NET プロジェクトで Deedle を使用するには、Deedle NuGet パッケージをインストールする必要があります。 NuGet コンソールで次のコマンドを実行します:
Install-Package Deedleインストールが完了したら、Deedle 名前空間をプロジェクトにインポートする必要があります:
using Deedle;using Deedle;Imports Deedle基本的なコード例
データフレームを作成して操作する基本的な例から始めましょう。 これにより、Deedle の基本を理解するのに役立ちます。
using System;
using Deedle;
class Program
{
static void Main()
{
// Creating a series with integer keys and double values
var series = new Series<int, double>(new[] { 1, 2, 3 }, new[] { 3.5, 4.2, 5.1 });
Console.WriteLine("Series:");
Console.WriteLine(series);
// Creating a data frame from a 2D array
var rowIndex = new[] { 1, 2, 3 };
var colIndex = new[] { "A", "B" };
var data = new double[,] { { 1.0, 3.5 }, { 2.0, 4.2 }, { 3.0, 5.1 } };
var dataFrame = Frame.FromArray2D(data)
.IndexRowsWith(rowIndex)
.IndexColumnsWith(colIndex);
Console.WriteLine("Data Frame:");
Console.WriteLine(dataFrame);
}
}using System;
using Deedle;
class Program
{
static void Main()
{
// Creating a series with integer keys and double values
var series = new Series<int, double>(new[] { 1, 2, 3 }, new[] { 3.5, 4.2, 5.1 });
Console.WriteLine("Series:");
Console.WriteLine(series);
// Creating a data frame from a 2D array
var rowIndex = new[] { 1, 2, 3 };
var colIndex = new[] { "A", "B" };
var data = new double[,] { { 1.0, 3.5 }, { 2.0, 4.2 }, { 3.0, 5.1 } };
var dataFrame = Frame.FromArray2D(data)
.IndexRowsWith(rowIndex)
.IndexColumnsWith(colIndex);
Console.WriteLine("Data Frame:");
Console.WriteLine(dataFrame);
}
}Imports System
Imports Deedle
Friend Class Program
Shared Sub Main()
' Creating a series with integer keys and double values
Dim series As New Series(Of Integer, Double)( { 1, 2, 3 }, { 3.5, 4.2, 5.1 })
Console.WriteLine("Series:")
Console.WriteLine(series)
' Creating a data frame from a 2D array
Dim rowIndex = { 1, 2, 3 }
Dim colIndex = { "A", "B" }
Dim data = New Double(, ) {
{ 1.0, 3.5 },
{ 2.0, 4.2 },
{ 3.0, 5.1 }
}
Dim dataFrame = Frame.FromArray2D(data).IndexRowsWith(rowIndex).IndexColumnsWith(colIndex)
Console.WriteLine("Data Frame:")
Console.WriteLine(dataFrame)
End Sub
End Classこの例では、整数の行キーと実数の値を持つシリーズを作成します。 次に、実数値の2D配列を使用してデータフレームを作成します。 行を整数で、列を文字列でインデックス付けします。
Deedle C# の機能を実装する
欠損値の処理
データ操作では欠損値の処理が重要です。 Deedle は欠損データを強力にサポートしています。 欠損値を含むシリーズを作成し、それらを処理するための操作を実行できます。
using System;
using Deedle;
class Program
{
static void Main()
{
// Creating a series with nullable doubles to represent missing values
var series = new Series<int, double?>(
new[] { 75, 8, 47, 5 },
new double?[] { 75.0, null, 47.0, 5.0 }
);
Console.WriteLine("Original Series with Missing Values:");
Console.WriteLine(series);
// Fill missing values with a specified value (e.g., 0.0)
var filledSeries = series.FillMissing(0.0);
Console.WriteLine("Series after Filling Missing Values:");
Console.WriteLine(filledSeries);
}
}using System;
using Deedle;
class Program
{
static void Main()
{
// Creating a series with nullable doubles to represent missing values
var series = new Series<int, double?>(
new[] { 75, 8, 47, 5 },
new double?[] { 75.0, null, 47.0, 5.0 }
);
Console.WriteLine("Original Series with Missing Values:");
Console.WriteLine(series);
// Fill missing values with a specified value (e.g., 0.0)
var filledSeries = series.FillMissing(0.0);
Console.WriteLine("Series after Filling Missing Values:");
Console.WriteLine(filledSeries);
}
}Imports System
Imports Deedle
Friend Class Program
Shared Sub Main()
' Creating a series with nullable doubles to represent missing values
Dim series As New Series(Of Integer, Double?)( { 75, 8, 47, 5 }, New Double?() { 75.0, Nothing, 47.0, 5.0 })
Console.WriteLine("Original Series with Missing Values:")
Console.WriteLine(series)
' Fill missing values with a specified value (e.g., 0.0)
Dim filledSeries = series.FillMissing(0.0)
Console.WriteLine("Series after Filling Missing Values:")
Console.WriteLine(filledSeries)
End Sub
End Classこの例では欠損値を持つシリーズを作成し、指定された値で埋めます。 また、より複雑なシナリオには ofOptionalObservations や ofValues のような静的メンバメソッドを利用できます。
データ操作
Deedle はさまざまなデータ操作タスクを実行できます。 データフレーム内のデータをフィルタリング、変換、集計できます。
using System;
using Deedle;
class Program
{
static void Main()
{
// Creating a data frame
var rowIndex = new[] { 1, 2, 3 };
var colIndex = new[] { "A", "B" };
var data = new double[,] { { 1.0, 3.5 }, { 2.0, 4.2 }, { 3.0, 5.1 } };
var dataFrame = Frame.FromArray2D(data)
.IndexRowsWith(rowIndex)
.IndexColumnsWith(colIndex);
Console.WriteLine("Original Data Frame:");
Console.WriteLine(dataFrame);
// Filter rows where column 'A' is greater than 1.5
var filteredFrame = dataFrame.Where(row => row.Value.GetAs<double>("A") > 1.5);
Console.WriteLine("Filtered Data Frame:");
Console.WriteLine(filteredFrame);
// Add a new column 'C' which is the sum of columns 'A' and 'B'
dataFrame.AddColumn("C", dataFrame["A"] + dataFrame["B"]);
Console.WriteLine("Transformed Data Frame with New Column 'C':");
Console.WriteLine(dataFrame);
}
}using System;
using Deedle;
class Program
{
static void Main()
{
// Creating a data frame
var rowIndex = new[] { 1, 2, 3 };
var colIndex = new[] { "A", "B" };
var data = new double[,] { { 1.0, 3.5 }, { 2.0, 4.2 }, { 3.0, 5.1 } };
var dataFrame = Frame.FromArray2D(data)
.IndexRowsWith(rowIndex)
.IndexColumnsWith(colIndex);
Console.WriteLine("Original Data Frame:");
Console.WriteLine(dataFrame);
// Filter rows where column 'A' is greater than 1.5
var filteredFrame = dataFrame.Where(row => row.Value.GetAs<double>("A") > 1.5);
Console.WriteLine("Filtered Data Frame:");
Console.WriteLine(filteredFrame);
// Add a new column 'C' which is the sum of columns 'A' and 'B'
dataFrame.AddColumn("C", dataFrame["A"] + dataFrame["B"]);
Console.WriteLine("Transformed Data Frame with New Column 'C':");
Console.WriteLine(dataFrame);
}
}Imports System
Imports Deedle
Friend Class Program
Shared Sub Main()
' Creating a data frame
Dim rowIndex = { 1, 2, 3 }
Dim colIndex = { "A", "B" }
Dim data = New Double(, ) {
{ 1.0, 3.5 },
{ 2.0, 4.2 },
{ 3.0, 5.1 }
}
Dim dataFrame = Frame.FromArray2D(data).IndexRowsWith(rowIndex).IndexColumnsWith(colIndex)
Console.WriteLine("Original Data Frame:")
Console.WriteLine(dataFrame)
' Filter rows where column 'A' is greater than 1.5
Dim filteredFrame = dataFrame.Where(Function(row) row.Value.GetAs(Of Double)("A") > 1.5)
Console.WriteLine("Filtered Data Frame:")
Console.WriteLine(filteredFrame)
' Add a new column 'C' which is the sum of columns 'A' and 'B'
dataFrame.AddColumn("C", dataFrame("A") + dataFrame("B"))
Console.WriteLine("Transformed Data Frame with New Column 'C':")
Console.WriteLine(dataFrame)
End Sub
End Classこの例では、条件に基づいて行をフィルタリングし、変換されたデータを含む新しい列を追加する方法を示します。 Deedle はデータ分析を簡単にするために標準のフレーム拡張メソッドを実装しています。
統計関数
Deedle はデータを分析するための標準的な統計関数を提供します。 統計関数を使用して、平均、標準偏差、その他の統計的指標を計算できます。
using System;
using Deedle;
class Program
{
static void Main()
{
// Creating a series with integer keys and double values
var series = new Series<int, double>(
new[] { 1, 2, 3, 4 },
new[] { 1.0, 2.0, 3.0, 4.0 }
);
Console.WriteLine("Series:");
Console.WriteLine(series);
// Calculate the mean of the series
var mean = series.Mean();
Console.WriteLine($"Mean: {mean}");
// Calculate the standard deviation of the series
var stddev = series.StdDev();
Console.WriteLine($"Standard Deviation: {stddev}");
}
}using System;
using Deedle;
class Program
{
static void Main()
{
// Creating a series with integer keys and double values
var series = new Series<int, double>(
new[] { 1, 2, 3, 4 },
new[] { 1.0, 2.0, 3.0, 4.0 }
);
Console.WriteLine("Series:");
Console.WriteLine(series);
// Calculate the mean of the series
var mean = series.Mean();
Console.WriteLine($"Mean: {mean}");
// Calculate the standard deviation of the series
var stddev = series.StdDev();
Console.WriteLine($"Standard Deviation: {stddev}");
}
}Imports System
Imports Deedle
Friend Class Program
Shared Sub Main()
' Creating a series with integer keys and double values
Dim series As New Series(Of Integer, Double)( { 1, 2, 3, 4 }, { 1.0, 2.0, 3.0, 4.0 })
Console.WriteLine("Series:")
Console.WriteLine(series)
' Calculate the mean of the series
Dim mean = series.Mean()
Console.WriteLine($"Mean: {mean}")
' Calculate the standard deviation of the series
Dim stddev = series.StdDev()
Console.WriteLine($"Standard Deviation: {stddev}")
End Sub
End Classこの Deedle コード例では、平均と標準偏差をそれぞれ計算するために標準的な統計関数 Mean() および StdDev() を実装しています。
CSV からのデータフレーム作成
Deedle は簡単に CSV ファイルからデータフレームを作成できます。 これは構造化データをロードして分析するのに役立ちます。
using System;
using Deedle;
class Program
{
static void Main()
{
// Load a data frame from a CSV file
var dataFrame = Frame.ReadCsv("data.csv");
Console.WriteLine("Data Frame from CSV:");
Console.WriteLine(dataFrame);
// Aggregate rows by a specified column and compute sum
var summary = dataFrame.AggregateRowsBy<string, double>(
new[] { "ColumnName" }, // rowKeys
null, // columnKeys, you can pass null if not required
v => v.Sum() // aggFunc
);
Console.WriteLine("Summary of Data Frame:");
Console.WriteLine(summary);
}
}using System;
using Deedle;
class Program
{
static void Main()
{
// Load a data frame from a CSV file
var dataFrame = Frame.ReadCsv("data.csv");
Console.WriteLine("Data Frame from CSV:");
Console.WriteLine(dataFrame);
// Aggregate rows by a specified column and compute sum
var summary = dataFrame.AggregateRowsBy<string, double>(
new[] { "ColumnName" }, // rowKeys
null, // columnKeys, you can pass null if not required
v => v.Sum() // aggFunc
);
Console.WriteLine("Summary of Data Frame:");
Console.WriteLine(summary);
}
}Imports System
Imports Deedle
Friend Class Program
Shared Sub Main()
' Load a data frame from a CSV file
Dim dataFrame = Frame.ReadCsv("data.csv")
Console.WriteLine("Data Frame from CSV:")
Console.WriteLine(dataFrame)
' Aggregate rows by a specified column and compute sum
Dim summary = dataFrame.AggregateRowsBy(Of String, Double)( { "ColumnName" }, Nothing, Function(v) v.Sum())
Console.WriteLine("Summary of Data Frame:")
Console.WriteLine(summary)
End Sub
End Classこの例では CSV ファイルをデータフレームに読み込み、データに対して要約操作を実行します。
IronPDF との統合
IronPDF の紹介

IronPDF は .NET アプリケーションで PDF ファイルを作成、操作、およびコンテンツを抽出する強力なライブラリです。 これは非常に多用途で、HTML からの PDF の生成、テキストの抽出、PDF の結合などさまざまな PDF 関連のタスクを処理できます。 IronPDF と Deedle を統合することで、データフレームから動的なレポートを生成する必要があるデータ分析や報告のシナリオで特に役立ちます。
IronPDF のインストール
NuGet パッケージ マネージャー コンソールを使用して .NET プロジェクトに IronPDF をインストールするには、次のコマンドを追加します:
Install-Package IronPdfまたは、ソリューション用の NuGet パッケージ マネージャーを使用して IronPDF をインストールすることもできます。 検索結果で IronPDF パッケージを NuGet で 探して選択し、次に"インストール"ボタンをクリックします。 Visual Studioはダウンロードとインストールを自動的に行います。
インストールが完了したら、IronPDF はプロジェクトで利用可能になります。
IronPDF と Deedle を組み合わせるユースケース
統計データを含むデータフレームがあり、それを PDF レポートで表示したいと想像してみてください。 Deedle はデータ操作と分析の部分を処理し、IronPDF は最終レポートのフォーマットと生成に使用できます。 例えば、データを分かち合いやすく提示できるように、表、チャート、および記述統計を含む PDF を生成できます。
ユースケースのコード例
IronPDF と Deedle を統合する方法を示す完全なコード例を紹介します。 Deedle データフレームからシンプルなレポートを作成し、IronPDF を使用して PDF を生成します。
using System;
using System.Linq;
using Deedle;
using IronPdf;
namespace DeedleIronPDFIntegration
{
class Program
{
static void Main(string[] args)
{
// Set IronPDF license key
IronPdf.License.LicenseKey = "License-Key";
// Create a sample data frame from in-memory records
var data = new[]
{
new { Name = "Robert", Age = 30, City = "New York" },
new { Name = "Johnny", Age = 25, City = "San Francisco" },
new { Name = "Charlie", Age = 35, City = "Los Angeles" }
};
var frame = Frame.FromRecords(data);
// Convert the data frame to an HTML table format
var htmlTable = "<table border='1' cellpadding='5' cellspacing='0'><thead><tr><th>Name</th><th>Age</th><th>City</th></tr></thead><tbody>" +
string.Join("", frame.Rows.Select(row =>
$"<tr><td>{row.Value.GetAs<string>("Name")}</td><td>{row.Value.GetAs<int>("Age")}</td><td>{row.Value.GetAs<string>("City")}</td></tr>")
) +
"</tbody></table>";
// Wrap the HTML table in basic HTML structure with CSS styling
var htmlContent = $@"
<html>
<head>
<style>
table {{
width: 100%;
border-collapse: collapse;
}}
th, td {{
border: 1px solid black;
padding: 8px;
text-align: left;
}}
th {{
background-color: #f2f2f2;
}}
</style>
</head>
<body>
{htmlTable}
</body>
</html>";
// Create a PDF from the HTML content
var renderer = new ChromePdfRenderer();
var pdfDocument = renderer.RenderHtmlAsPdf(htmlContent);
// Save the generated PDF to a file
pdfDocument.SaveAs("f:\\DeedleReport.pdf");
Console.WriteLine("PDF report created successfully!");
}
}
}using System;
using System.Linq;
using Deedle;
using IronPdf;
namespace DeedleIronPDFIntegration
{
class Program
{
static void Main(string[] args)
{
// Set IronPDF license key
IronPdf.License.LicenseKey = "License-Key";
// Create a sample data frame from in-memory records
var data = new[]
{
new { Name = "Robert", Age = 30, City = "New York" },
new { Name = "Johnny", Age = 25, City = "San Francisco" },
new { Name = "Charlie", Age = 35, City = "Los Angeles" }
};
var frame = Frame.FromRecords(data);
// Convert the data frame to an HTML table format
var htmlTable = "<table border='1' cellpadding='5' cellspacing='0'><thead><tr><th>Name</th><th>Age</th><th>City</th></tr></thead><tbody>" +
string.Join("", frame.Rows.Select(row =>
$"<tr><td>{row.Value.GetAs<string>("Name")}</td><td>{row.Value.GetAs<int>("Age")}</td><td>{row.Value.GetAs<string>("City")}</td></tr>")
) +
"</tbody></table>";
// Wrap the HTML table in basic HTML structure with CSS styling
var htmlContent = $@"
<html>
<head>
<style>
table {{
width: 100%;
border-collapse: collapse;
}}
th, td {{
border: 1px solid black;
padding: 8px;
text-align: left;
}}
th {{
background-color: #f2f2f2;
}}
</style>
</head>
<body>
{htmlTable}
</body>
</html>";
// Create a PDF from the HTML content
var renderer = new ChromePdfRenderer();
var pdfDocument = renderer.RenderHtmlAsPdf(htmlContent);
// Save the generated PDF to a file
pdfDocument.SaveAs("f:\\DeedleReport.pdf");
Console.WriteLine("PDF report created successfully!");
}
}
}Imports System
Imports System.Linq
Imports Deedle
Imports IronPdf
Namespace DeedleIronPDFIntegration
Friend Class Program
Shared Sub Main(ByVal args() As String)
' Set IronPDF license key
IronPdf.License.LicenseKey = "License-Key"
' Create a sample data frame from in-memory records
Dim data = {
New With {
Key .Name = "Robert",
Key .Age = 30,
Key .City = "New York"
},
New With {
Key .Name = "Johnny",
Key .Age = 25,
Key .City = "San Francisco"
},
New With {
Key .Name = "Charlie",
Key .Age = 35,
Key .City = "Los Angeles"
}
}
Dim frame = Frame.FromRecords(data)
' Convert the data frame to an HTML table format
Dim htmlTable = "<table border='1' cellpadding='5' cellspacing='0'><thead><tr><th>Name</th><th>Age</th><th>City</th></tr></thead><tbody>" & String.Join("", frame.Rows.Select(Function(row) $"<tr><td>{row.Value.GetAs(Of String)("Name")}</td><td>{row.Value.GetAs(Of Integer)("Age")}</td><td>{row.Value.GetAs(Of String)("City")}</td></tr>")) & "</tbody></table>"
' Wrap the HTML table in basic HTML structure with CSS styling
Dim htmlContent = $"
<html>
<head>
<style>
table {{
width: 100%;
border-collapse: collapse;
}}
th, td {{
border: 1px solid black;
padding: 8px;
text-align: left;
}}
th {{
background-color: #f2f2f2;
}}
</style>
</head>
<body>
{htmlTable}
</body>
</html>"
' Create a PDF from the HTML content
Dim renderer = New ChromePdfRenderer()
Dim pdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
' Save the generated PDF to a file
pdfDocument.SaveAs("f:\DeedleReport.pdf")
Console.WriteLine("PDF report created successfully!")
End Sub
End Class
End Namespace出力

これでおしまいです! Deedle から複雑なデータを取り込み、エレガントな PDF レポートを IronPDF の .NET PDF ライブラリ を使用して生成する完全機能のアプリケーションを作成しました。 データ分析結果をプロフェッショナルなフォーマットで伝える強力な方法です。
結論
この記事では、データフレームから動的な PDF レポートを作成するために Deedle と IronPDF を統合する方法を探りました。 Deedle を使用すれば、効率的にデータを操作および分析でき、IronPDF は最終 PDF ドキュメントの作成とフォーマットを処理します。 この組み合わせにより、データ分析からプレゼンテーションまでのプロセスを自動化し、簡単にプロフェッショナルなレポートを生成することができます。
IronPDF は多くの機能や利用法についての詳細なドキュメントと、始め方および豊富な機能を効果的に使用するためのさまざまなIronPDF コード例 を提供しています。
IronPDF のライセンス オプション を $799 から探ってみてください。 試してみて、それがあなたの報告能力をどのように向上させるか確認してください。
よくある質問
Deedle C#は何に使われますか?
Deedle C#はデータの操作と分析に使用され、構造化されたデータフレームとシリーズを効率的に処理するツールを提供します。特にデータサイエンスアプリケーションでは、欠損データの管理、データの整列、および関数の適用が可能です。
Deedle を .NET での PDF 生成とどのように統合できますか?
DeedleをIronPDFと組み合わせて、データフレームから動的なPDFレポートを生成できます。Deedleがデータ操作を担当する一方で、IronPDFは最終的なPDFレポートをテーブル、チャート、統計を含む形でフォーマットおよび生成します。
.NETプロジェクトにDeedleをどのようにインストールしますか?
.NETプロジェクトにDeedleをインストールするには、Visual Studioを使用して新しいC#コンソールアプリケーションを作成し、コマンドInstall-Package Deedleを使用してDeedle NuGetパッケージをインストールし、using Deedle;をプロジェクトに含めます。
CSVファイルからDeedleを使用してデータフレームを作成するプロセスは何ですか?
Deedleを使用してCSVファイルからデータフレームを作成するには、Frame.ReadCsv()メソッドを使用できます。これにより、CSVファイルから構造化されたデータを読み込み、データフレームとして分析や操作が可能です。
Deedleはデータフレーム内の欠損値を処理できますか?
はい、Deedleはデータフレーム内の欠損値を処理するための強力なサポートを提供します。FillMissing()などの関数を使用して、シリーズまたはデータフレーム内で適切に欠損データを管理および補完することができます。
Deedleを使用して統計分析をどのように行うことができますか?
Deedleには組み込みの統計関数があり、データフレームやシリーズに直接平均、標準偏差、その他の統計指標の計算を行うことができます。
.NETでデータフレームからPDFレポートをどのように生成しますか?
.NETでデータフレームからPDFレポートを生成するには、Deedleをデータ操作に、IronPDFをPDF生成に使用します。Deedleでデータを操作した後、IronPDFを使用して、プロフェッショナルにスタイル化されたPDFレポートにデータをフォーマットおよび出力します。








