Skip to content

Commit 64465fe

Browse files
committed
more files
1 parent cbac109 commit 64465fe

File tree

3 files changed

+572
-0
lines changed

3 files changed

+572
-0
lines changed

MsDataFrame.ipynb

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"data": {
10+
"text/html": [
11+
"Installing package Microsoft.Data.Analysis...............................done!"
12+
]
13+
},
14+
"metadata": {},
15+
"output_type": "display_data"
16+
},
17+
{
18+
"data": {
19+
"text/html": [
20+
"Successfully added reference to package Microsoft.Data.Analysis, version 0.2.0"
21+
]
22+
},
23+
"metadata": {},
24+
"output_type": "display_data"
25+
}
26+
],
27+
"source": [
28+
"#r \"nuget:Microsoft.Data.Analysis\"\n",
29+
"using Microsoft.Data.Analysis;"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": 13,
35+
"metadata": {},
36+
"outputs": [],
37+
"source": [
38+
"PrimitiveDataFrameColumn<DateTime> dateTimes = new PrimitiveDataFrameColumn<DateTime>(\"DateTimes\",3); // Default length is 0.\n",
39+
"PrimitiveDataFrameColumn<int> ints = new PrimitiveDataFrameColumn<int>(\"Ints\", 3); // Makes a column of length 3. Filled with nulls initially\n",
40+
"StringDataFrameColumn strings = new StringDataFrameColumn(\"Strings\", 3); // Makes a column of length 3. Filled with nulls initially\n"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": 14,
46+
"metadata": {},
47+
"outputs": [],
48+
"source": [
49+
"DataFrame df = new DataFrame(dateTimes, ints, strings);"
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": 15,
55+
"metadata": {},
56+
"outputs": [],
57+
"source": [
58+
"using Microsoft.AspNetCore.Html;\n",
59+
"Formatter<DataFrame>.Register((df, writer) =>\n",
60+
"{\n",
61+
" var headers = new List<IHtmlContent>();\n",
62+
" headers.Add(th(i(\"index\")));\n",
63+
" headers.AddRange(df.Columns.Select(c => (IHtmlContent) th(c.Name)));\n",
64+
" var rows = new List<List<IHtmlContent>>();\n",
65+
" var take = 20;\n",
66+
" for (var i = 0; i < Math.Min(take, df.Rows.Count); i++)\n",
67+
" {\n",
68+
" var cells = new List<IHtmlContent>();\n",
69+
" cells.Add(td(i));\n",
70+
" foreach (var obj in df.Rows[i])\n",
71+
" {\n",
72+
" cells.Add(td(obj));\n",
73+
" }\n",
74+
" rows.Add(cells);\n",
75+
" }\n",
76+
"\n",
77+
" var t = table(\n",
78+
" thead(\n",
79+
" headers),\n",
80+
" tbody(\n",
81+
" rows.Select(\n",
82+
" r => tr(r))));\n",
83+
"\n",
84+
" writer.Write(t);\n",
85+
"}, \"text/html\");"
86+
]
87+
},
88+
{
89+
"cell_type": "code",
90+
"execution_count": 16,
91+
"metadata": {},
92+
"outputs": [
93+
{
94+
"data": {
95+
"text/html": [
96+
"<table><thead><th><i>index</i></th><th>DateTimes</th><th>Ints</th><th>Strings</th></thead><tbody><tr><td>0</td><td>&lt;null&gt;</td><td>&lt;null&gt;</td><td>&lt;null&gt;</td></tr><tr><td>1</td><td>&lt;null&gt;</td><td>&lt;null&gt;</td><td>&lt;null&gt;</td></tr><tr><td>2</td><td>&lt;null&gt;</td><td>&lt;null&gt;</td><td>&lt;null&gt;</td></tr></tbody></table>"
97+
]
98+
},
99+
"execution_count": 16,
100+
"metadata": {},
101+
"output_type": "execute_result"
102+
}
103+
],
104+
"source": [
105+
"df"
106+
]
107+
}
108+
],
109+
"metadata": {
110+
"kernelspec": {
111+
"display_name": ".NET (C#)",
112+
"language": "C#",
113+
"name": ".net-csharp"
114+
},
115+
"language_info": {
116+
"file_extension": ".cs",
117+
"mimetype": "text/x-csharp",
118+
"name": "C#",
119+
"pygments_lexer": "csharp",
120+
"version": "8.0"
121+
}
122+
},
123+
"nbformat": 4,
124+
"nbformat_minor": 2
125+
}

0 commit comments

Comments
 (0)