缩短数据集的长度

发布于 2025-02-08 03:54:41 字数 926 浏览 1 评论 0原文

我有一个像这样的数据集,继续进行了数千行,我试图实现的一种方法是缩短数据集的一种方法,因此,在数据集包含多行,同一层在连续左右左上左上列出了相同的层和屁股行。在这种情况下,将是什么意思:

”数据集的示例,并具有提取标记的值“

boriddepth1depth2layer
b1(192.2215)0.10.8S
B1(192.2215)0.8 2.42.4 2.4ml
b1(192.2215)(192.2215)2.43.9 3.9 3.93.9 3.9 3.9 3.9
B1(192.2215)3.910.7ML
B1(192.2215)10.713.5S

是否有任何方法可以实现从每个DEAPTH1获得最低值的最低值,而从每个DEAPTH2的最高值则是相同的值?

Borid是一个独特的钥匙

I have a dataset like this, goes on for many thousands of rows, what im trying to achive is a way to shorten the dataset so in the case that the dataset contains multiple rows with the same layer sort in a row im left with the top and buttom rows. In this case what would mean something like this:

Example of data set, with values needed to extract marked

BorIDDepth1Depth2Layer
B1(192.2215)0.10.8S
B1(192.2215)0.82.4ML
B1(192.2215)2.43.9S
B1(192.2215)3.910.7ML
B1(192.2215)10.713.5S

Is there any way to achive that getting the lowest value from each Deapth1 and the highest value from each Deapth2 if Layer is the same value?

BorID is a unique key

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

染火枫林 2025-02-15 03:54:41

尝试此

(a)创建所有行的偏移,以便我可以与(b)下方的值进行比较,如果borid或layer有差异,然后使用rowID,否则使用null(c)填写新列(d) )该列和分组中的组在该表(e)的第一行和最后一行中创建表(e)的最后一行,然后删除额外的列

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],

//offset data one row
    MinusOne =  #table({"Column1"}, {{null}}) & Table.Skip(Table.DemoteHeaders(Table.RemoveLastN(Source,1)),1),
    custom1 = Table.ToColumns(Source) & Table.ToColumns(MinusOne ), 
    custom2 = Table.FromColumns(custom1,Table.ColumnNames(Source)&Table.ColumnNames(MinusOne ) ),

#"Added Custom" = Table.AddColumn(custom2, "Custom", each if [BorID]<>[Column1] or [Layer]<>[Column5] then [Rowid] else null),
#"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"}),
#"Grouped Rows" = Table.Group(#"Filled Down", {"Custom"}, {{"Count", each 
         #table(
             {"BorId","Depth1","Depth2","Layer"},
             {{
                  Table.FirstN(_,1){0}[BorID],
                  Table.FirstN(_,1){0}[Depth1],
                  Table.LastN(_,1){0}[Depth2],
                  Table.FirstN(_,1){0}[Layer]
             }}
          )
, type table}}),
#"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"BorId", "Depth1", "Depth2", "Layer"}, {"BorId", "Depth1", "Depth2", "Layer"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Count",{"Custom"})  
in #"Removed Columns"

boriddepth1 depth2borid depth2hicknesslayshictt
“ https://i.sstatic.net/jvmql.jpg” alt=“ nofollow noreferrer”>S1ML1
a0.150.49S2S2
a0.40.86S3S3
a0.81.259ML4S4
a1.251.755ML5ML5
a1.752.47ML6ML6
a2.42.754S7ML7
a2.753.253S8ml8
A3.253.97S9ml9
A3.94.256ml10ml10
A4.25 4.254.754ml11ml11
A4.755.251ml 12ml 12ml12ml12
a5.255.754ml 13ml 13ml13ml13
a5.75 6.25 6.256.25 6.254 ml 14 ml 14 ml 14 ml 14ml14 ml14
a6.25 6.256.25 6.25 6.256.25 6.75 4mml 4 ml ml l ml15ml15
A6.757.254ml16ml16
A7.25 7.753.753ml17ml17
a7.758.254ml18S18
a8.254.25 4.254ml19s 19s19
a8.789.11ml20s20
a9.1 9.19.1 9.1 9.18ml21s 21 a 9.75 10 a 9.7510
a9.759.758 8ml22s 22s 22s22s 22
A10.510.758S23S23
A10.7511.58S24S24
a11.5 11.511.83S25S25
a11.812.258S26S 26S26
a12.25 12.7512.754S27S 27S 27S27
a12.75 13.2513.25 13.253S28S28S 28S
28 a13.2513.259s29s29s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s 29 s

Try this

(a) created an offset of all rows so I can compare to values of row beneath (b) if there is a difference in BorID or Layer then use the RowID, otherwise use null (c) fill that new column down (d) group on that column and in the grouping, create table from first row and last row of that table (e) expand and remove extra column

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],

//offset data one row
    MinusOne =  #table({"Column1"}, {{null}}) & Table.Skip(Table.DemoteHeaders(Table.RemoveLastN(Source,1)),1),
    custom1 = Table.ToColumns(Source) & Table.ToColumns(MinusOne ), 
    custom2 = Table.FromColumns(custom1,Table.ColumnNames(Source)&Table.ColumnNames(MinusOne ) ),

#"Added Custom" = Table.AddColumn(custom2, "Custom", each if [BorID]<>[Column1] or [Layer]<>[Column5] then [Rowid] else null),
#"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"}),
#"Grouped Rows" = Table.Group(#"Filled Down", {"Custom"}, {{"Count", each 
         #table(
             {"BorId","Depth1","Depth2","Layer"},
             {{
                  Table.FirstN(_,1){0}[BorID],
                  Table.FirstN(_,1){0}[Depth1],
                  Table.LastN(_,1){0}[Depth2],
                  Table.FirstN(_,1){0}[Layer]
             }}
          )
, type table}}),
#"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"BorId", "Depth1", "Depth2", "Layer"}, {"BorId", "Depth1", "Depth2", "Layer"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Count",{"Custom"})  
in #"Removed Columns"

enter image description here

BorIDDepth1Depth2Latert hicknessLayerLayer sortRowid
a0.10.155S1ML1
a0.150.49S2S2
a0.40.86S3S3
a0.81.259ML4S4
a1.251.755ML5ML5
a1.752.47ML6ML6
a2.42.754S7ML7
a2.753.253S8ML8
a3.253.97S9ML9
a3.94.256ML10ML10
a4.254.754ML11ML11
a4.755.251ML12ML12
a5.255.754ML13ML13
a5.756.254ML14ML14
a6.256.754ML15ML15
a6.757.254ML16ML16
a7.257.753ML17ML17
a7.758.254ML18S18
a8.258.754ML19S19
a8.789.11ML20S20
a9.19.758ML21S21
a9.7510.58ML22S22
a10.510.758S23S23
a10.7511.58S24S24
a11.511.83S25S25
a11.812.258S26S26
a12.2512.754S27S27
a12.7513.253S28S28
a13.2513.59S29S29
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文