dolphindb 2.0.801 → 2.0.901

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs.en.json CHANGED
@@ -940,7 +940,7 @@
940
940
  {
941
941
  "type": "text",
942
942
  "value": [
943
- "`table` can be a table of any type, such as an in-memory table, a stream table, a DFS table, or a dimension table.",
943
+ "`table` can be an in-memory table, a stream table, a DFS table, or a dimension table.",
944
944
  "",
945
945
  "`colNames` is a string scalar/vector indicating the name(s) of the column(s) to be added.",
946
946
  "",
@@ -1804,6 +1804,270 @@
1804
1804
  }
1805
1805
  ]
1806
1806
  },
1807
+ "align": {
1808
+ "title": "align",
1809
+ "type": "function",
1810
+ "children": [
1811
+ {
1812
+ "title": "Syntax",
1813
+ "type": "grammer",
1814
+ "children": [
1815
+ {
1816
+ "type": "text",
1817
+ "value": [
1818
+ "align(left, right, [how='outer'], [byRow], [view=true])"
1819
+ ]
1820
+ }
1821
+ ]
1822
+ },
1823
+ {
1824
+ "title": "Arguments",
1825
+ "type": "parameters",
1826
+ "children": [
1827
+ {
1828
+ "type": "text",
1829
+ "value": [
1830
+ "`left` and `right` are both matrices with column and/or row labels.",
1831
+ "",
1832
+ "`how` indicates the join method with which the two matrices are aligned. The matrices are aligned on the column labels and/or row labels. It can be 'outer' (or 'fj'), 'inner' (or 'ej'), 'left' (or 'lj') or 'asof ('aj')'. The default value is 'outer', indicating outer join.",
1833
+ "",
1834
+ "`byRow` is a Boolean or NULL value.",
1835
+ "",
1836
+ "- true: align the matrices on row labels.",
1837
+ "- false: align on the column labels.",
1838
+ "- NULL (default): align on the row labels and the column labels. Specify how in the format of \"<row_alignment>,<column alignment>\", e.g., ``how=\"outer,inner\"``. Do not add a space or special character before or after the comma. If the same alignment method is used on rows and columns, it only needs to be specified once, e.g., ``how=\"inner\"``.",
1839
+ "",
1840
+ "Note: The *left* and *right* matrices must both have the required labels (based on the value of *byRow*). The columns with the same label in both tables must have compatible data type. The supported data types and compatibility rules are as follows:",
1841
+ "",
1842
+ "- integral (INT, SHORT, LONG and CHAR are compatible data types)",
1843
+ "- floating (FLOAT and DOUBLE are compatible )",
1844
+ "- temporal",
1845
+ "- STRING and SYMBOL (compatible data types) ",
1846
+ "",
1847
+ "`view` is a Boolean value. The default value is true, indicating the result will be a view of the original matrix (shallow copy) and changes made to the original matrix will be reflected in the view. If set to false, the result will be a new matrix (deep copy). "
1848
+ ]
1849
+ }
1850
+ ]
1851
+ },
1852
+ {
1853
+ "title": "Details",
1854
+ "type": "detail",
1855
+ "children": [
1856
+ {
1857
+ "type": "text",
1858
+ "value": [
1859
+ "Align the left and right matrices based on row labels and/or column labels (specified by *byRow*) using the join method specified by *how*. Return a tuple with 2 aligned matrices.",
1860
+ "",
1861
+ "Note:",
1862
+ "",
1863
+ "- The aligned matrices do not keep the attributes of the original matrices. For instance, an indexed matrix will no longer have index after the alignment.",
1864
+ "",
1865
+ "- To add column/row labels to a matrix, call ``rename!``. Use the SQL keywords ``exec`` and ``pivot by`` to create a matrix with the columns specified in the ``pivot by`` clause as the matrix labels (see :doc:`/SQLStatements/pivotBy`). "
1866
+ ]
1867
+ }
1868
+ ]
1869
+ },
1870
+ {
1871
+ "title": "Context",
1872
+ "children": [
1873
+ {
1874
+ "type": "text",
1875
+ "value": [
1876
+ "Prior to version 1.30.20/2.10.0, matrices must be converted to indexed matrices/series for binary operations. As the matrix/series will be aligned on index (with \"outer\" join), they must be monotonically increasing. ",
1877
+ "",
1878
+ "With the align function, alignment between matrices are more flexible in the following aspects:",
1879
+ "",
1880
+ "- Alignment between non-indexed matrices are supported. The matrices can be aligned on column/row labels which do not have to be monotonically increasing.",
1881
+ "",
1882
+ "- More options for the alignment methods."
1883
+ ]
1884
+ }
1885
+ ]
1886
+ },
1887
+ {
1888
+ "title": "Examples",
1889
+ "type": "example",
1890
+ "children": [
1891
+ {
1892
+ "type": "code",
1893
+ "language": "console",
1894
+ "value": [
1895
+ " ",
1896
+ " // align matrices with overlapping labels",
1897
+ " $ x1 = [09:00:00, 09:00:01, 09:00:03]",
1898
+ " $ x2 = [09:00:00, 09:00:03, 09:00:03, 09:00:04]",
1899
+ " $ m1 = matrix(1 2 3, 2 3 4, 3 4 5).rename!(x1)",
1900
+ " $ m2 = matrix(11 12 13, 12 13 14, 13 14 15, 14 15 16).rename!(x2)",
1901
+ " $ a, b = align(m1, m2, 'fj', false);",
1902
+ " $ a;",
1903
+ ""
1904
+ ]
1905
+ },
1906
+ {
1907
+ "type": "text",
1908
+ "value": [
1909
+ "+----------+----------+----------+----------+----------+",
1910
+ "| 09:00:00 | 09:00:01 | 09:00:03 | 09:00:03 | 09:00:04 |",
1911
+ "+==========+==========+==========+==========+==========+",
1912
+ "| 1 | 2 | 3 | 3 | |",
1913
+ "+----------+----------+----------+----------+----------+",
1914
+ "| 2 | 3 | 4 | 4 | |",
1915
+ "+----------+----------+----------+----------+----------+",
1916
+ "| 3 | 4 | 5 | 5 | |",
1917
+ "+----------+----------+----------+----------+----------+",
1918
+ ""
1919
+ ]
1920
+ },
1921
+ {
1922
+ "type": "code",
1923
+ "language": "console",
1924
+ "value": [
1925
+ "",
1926
+ " $ b;",
1927
+ ""
1928
+ ]
1929
+ },
1930
+ {
1931
+ "type": "text",
1932
+ "value": [
1933
+ "+----------+----------+----------+----------+----------+",
1934
+ "| 09:00:00 | 09:00:01 | 09:00:03 | 09:00:03 | 09:00:04 |",
1935
+ "+==========+==========+==========+==========+==========+",
1936
+ "| 11 | | 12 | 13 | 14 |",
1937
+ "+----------+----------+----------+----------+----------+",
1938
+ "| 12 | | 13 | 14 | 15 |",
1939
+ "+----------+----------+----------+----------+----------+",
1940
+ "| 13 | | 14 | 15 | 16 |",
1941
+ "+----------+----------+----------+----------+----------+",
1942
+ ""
1943
+ ]
1944
+ },
1945
+ {
1946
+ "type": "code",
1947
+ "language": "console",
1948
+ "value": [
1949
+ "",
1950
+ " $ a+b;",
1951
+ ""
1952
+ ]
1953
+ },
1954
+ {
1955
+ "type": "text",
1956
+ "value": [
1957
+ "+----------+----------+----------+----------+----------+",
1958
+ "| 09:00:00 | 09:00:01 | 09:00:03 | 09:00:03 | 09:00:04 |",
1959
+ "+==========+==========+==========+==========+==========+",
1960
+ "| 16 | | 19 | 20 | |",
1961
+ "+----------+----------+----------+----------+----------+",
1962
+ "| 12 | | 15 | 16 | |",
1963
+ "+----------+----------+----------+----------+----------+",
1964
+ "| 14 | | 17 | 18 | |",
1965
+ "+----------+----------+----------+----------+----------+",
1966
+ ""
1967
+ ]
1968
+ },
1969
+ {
1970
+ "type": "code",
1971
+ "language": "console",
1972
+ "value": [
1973
+ "",
1974
+ " $ m = align(m1, m2, 'aj', false);",
1975
+ " $ m[0];",
1976
+ ""
1977
+ ]
1978
+ },
1979
+ {
1980
+ "type": "text",
1981
+ "value": [
1982
+ "+----------+----------+----------+",
1983
+ "| 09:00:00 | 09:00:01 | 09:00:03 |",
1984
+ "+==========+==========+==========+",
1985
+ "| 1 | 2 | 3 |",
1986
+ "+----------+----------+----------+",
1987
+ "| 2 | 3 | 4 |",
1988
+ "+----------+----------+----------+",
1989
+ "| 3 | 4 | 5 |",
1990
+ "+----------+----------+----------+",
1991
+ ""
1992
+ ]
1993
+ },
1994
+ {
1995
+ "type": "code",
1996
+ "language": "console",
1997
+ "value": [
1998
+ "",
1999
+ " $ m[1];",
2000
+ ""
2001
+ ]
2002
+ },
2003
+ {
2004
+ "type": "text",
2005
+ "value": [
2006
+ "+----------+----------+----------+",
2007
+ "| 09:00:00 | 09:00:01 | 09:00:03 |",
2008
+ "+==========+==========+==========+",
2009
+ "| 11 | 11 | 13 |",
2010
+ "+----------+----------+----------+",
2011
+ "| 12 | 12 | 14 |",
2012
+ "+----------+----------+----------+",
2013
+ "| 13 | 13 | 15 |",
2014
+ "+----------+----------+----------+",
2015
+ ""
2016
+ ]
2017
+ },
2018
+ {
2019
+ "type": "code",
2020
+ "language": "console",
2021
+ "value": [
2022
+ "",
2023
+ " //create table pt for prices and vt for trading volumes",
2024
+ " $ timestamp = [09:00:00, 09:00:02, 09:00:03, 09:00:06, 09:00:08]",
2025
+ " $ id= ['st1', 'st2', 'st1', 'st1', 'st2']",
2026
+ " $ price = [197.8, 197.5, 198.4, 198.6, 198.6]",
2027
+ " $ pt = table(timestamp, id, price)",
2028
+ "",
2029
+ " $ timestamp = [09:00:00, 09:00:01, 09:00:02, 09:00:05, 09:00:08]",
2030
+ " $ id = ['st1', 'st2', 'st2', 'st3', 'st2']",
2031
+ " $ vol = [200, 300, 150, 200, 180] ",
2032
+ " $ vt = table(timestamp, id, vol)",
2033
+ "",
2034
+ " // convert vt and pt to matrices. Use the columns specified by “pivot by” as labels for the matrices",
2035
+ " $ m1 = exec vol from vt pivot by timestamp, id",
2036
+ " $ m2 = exec price from pt pivot by timestamp, id",
2037
+ "",
2038
+ " // align the matrices using the full join method",
2039
+ " $ m = align(m1, m2, how='aj,fj')",
2040
+ " ",
2041
+ " // get the matrix of the total trading value ",
2042
+ " $ re = m[0] * m[1]",
2043
+ " $ re;",
2044
+ ""
2045
+ ]
2046
+ },
2047
+ {
2048
+ "type": "text",
2049
+ "value": [
2050
+ "+----------+-------+-------+-----+",
2051
+ "| label | st1 | st2 | st3 |",
2052
+ "+==========+=======+=======+=====+",
2053
+ "| 09:00:00 | 39560 | | |",
2054
+ "+----------+-------+-------+-----+",
2055
+ "| 09:00:01 | | | |",
2056
+ "+----------+-------+-------+-----+",
2057
+ "| 09:00:02 | | 29625 | |",
2058
+ "+----------+-------+-------+-----+",
2059
+ "| 09:00:03 | | | |",
2060
+ "+----------+-------+-------+-----+",
2061
+ "| 09:00:05 | | | |",
2062
+ "+----------+-------+-------+-----+",
2063
+ "| 09:00:08 | | 35748 | |",
2064
+ "+----------+-------+-------+-----+"
2065
+ ]
2066
+ }
2067
+ ]
2068
+ }
2069
+ ]
2070
+ },
1807
2071
  "all": {
1808
2072
  "title": "all",
1809
2073
  "type": "function",
@@ -8771,7 +9035,7 @@
8771
9035
  {
8772
9036
  "type": "text",
8773
9037
  "value": [
8774
- "`retentionTime`is the amount of time to keep a log file. The default value is 30 (in days)."
9038
+ "`retentionTime` is the amount of time to keep a log file. The default value is 30 (in days)."
8775
9039
  ]
8776
9040
  }
8777
9041
  ]
@@ -10086,7 +10350,8 @@
10086
10350
  {
10087
10351
  "type": "text",
10088
10352
  "value": [
10089
- "If X is a string/char, form a new string by appending X with Y. If X is a string vector, Y serves as the separator between the elements in vector X and the function returns a string object."
10353
+ "- If X is a string/char, form a new string by appending X with Y. ",
10354
+ "- If X is a string vector, Y serves as the separator between the elements in vector X and the function returns a string object."
10090
10355
  ]
10091
10356
  }
10092
10357
  ]
@@ -10099,15 +10364,15 @@
10099
10364
  "type": "code",
10100
10365
  "language": "console",
10101
10366
  "value": [
10102
- " ",
10367
+ "",
10368
+ " // join two strings",
10103
10369
  " $ concat (`hello, `world);",
10104
10370
  " helloworld",
10105
10371
  "",
10106
- " $ x = concat(`IBM`GOOG`APPL, \"\\n\");",
10372
+ " // join IBM, GOOG and APPL with \",\" as the delimiter",
10373
+ " $ x = concat(`IBM`GOOG`APPL, \",\");",
10107
10374
  " $ x;",
10108
- " IBM",
10109
- " GOOG",
10110
- " APPL",
10375
+ " IBM,GOOG,APPL",
10111
10376
  "",
10112
10377
  " $ typestr x;",
10113
10378
  " STRING",
@@ -13553,7 +13818,7 @@
13553
13818
  {
13554
13819
  "type": "text",
13555
13820
  "value": [
13556
- "Example 1. Create a partitioned DFS table on disk. ",
13821
+ "Example 1. Create a DFS table",
13557
13822
  ""
13558
13823
  ]
13559
13824
  },
@@ -13563,18 +13828,16 @@
13563
13828
  "value": [
13564
13829
  "",
13565
13830
  " $ n=1000000;",
13566
- " $ t=table(rand(`IBM`MS`APPL`AMZN,n) as symbol, rand(10.0, n) as value)",
13831
+ " $ t=table(2020.01.01T00:00:00 + 0..(n-1) as timestamp, rand(`IBM`MS`APPL`AMZN,n) as symbol, rand(10.0, n) as value)",
13567
13832
  " $ db = database(\"dfs://rangedb_tradedata\", RANGE, `A`F`M`S`ZZZZ)",
13568
- " $ Trades = db.createPartitionedTable(t, \"Trades\", \"symbol\");",
13833
+ " $ Trades = db.createPartitionedTable(table=t, tableName=\"Trades\", partitionColumns=\"symbol\", compressMethods={timestamp:\"delta\"});",
13569
13834
  ""
13570
13835
  ]
13571
13836
  },
13572
13837
  {
13573
13838
  "type": "text",
13574
13839
  "value": [
13575
- "At this point, the table Trades is empty. We only established the structure of Trades following the structure of t. Next, we append the empty table Trades with table t to create a partitioned table of t.",
13576
- "",
13577
- "At this point, the table Trades is empty. The schema of `Trades` is the same as the schema of table `t`. Next, we append table `t` to table `Trades`.",
13840
+ "At this point, the table Trades is empty. The schema of *Trades* is the same as the schema of table *t*. Next, we append table *t* to table *Trades*.",
13578
13841
  ""
13579
13842
  ]
13580
13843
  },
@@ -13590,7 +13853,7 @@
13590
13853
  {
13591
13854
  "type": "text",
13592
13855
  "value": [
13593
- "Now the contents of table Trades have been updated on disk. In the local file system, the system doesn't dynamically refresh the contents of tables. We need to load the table into memory before we can work with it interactively.",
13856
+ "Now the contents of table Trades have been updated on disk. In the local file system, the system does not dynamically refresh the contents of tables. We need to load the table into memory before we can work with it interactively.",
13594
13857
  ""
13595
13858
  ]
13596
13859
  },
@@ -13610,7 +13873,7 @@
13610
13873
  "value": [
13611
13874
  "The in-memory table `t` is saved as a DFS table Trades on disk.",
13612
13875
  "",
13613
- "After appending data to a DFS table, we don't need to use function ``loadTable`` to load the table before querying the table, as the distributed file system automatically refreshes the table after appending operations. After system restarts, however, we need to use ``loadTable`` to load a DFS table before querying the table. ",
13876
+ "After appending data to a DFS table, we don't need to use function :doc:`../l/loadTable` to load the table before querying the table, as the distributed file system automatically refreshes the table after appending operations. After system restarts, however, we need to use ``loadTable`` to load a DFS table before querying the table. ",
13614
13877
  "",
13615
13878
  ".. Example 2. Create a partitioned table in a local database on disk.",
13616
13879
  "",
@@ -13622,7 +13885,7 @@
13622
13885
  "",
13623
13886
  "Example 2. Create in-memory partitioned tables",
13624
13887
  "",
13625
- "Example 2.1. Create an ordinary partitioned in-memory table. ",
13888
+ "Example 2.1. Create a partitioned in-memory table ",
13626
13889
  ""
13627
13890
  ]
13628
13891
  },
@@ -13646,7 +13909,7 @@
13646
13909
  {
13647
13910
  "type": "text",
13648
13911
  "value": [
13649
- "Example 2.2. Create a partitioned keyed table. ",
13912
+ "Example 2.2. Create a partitioned keyed table ",
13650
13913
  ""
13651
13914
  ]
13652
13915
  },
@@ -13741,29 +14004,8 @@
13741
14004
  "09:30:00.001 AAPL 100 56.5",
13742
14005
  "09:30:01.001 DELL 100 15.5",
13743
14006
  "============= ===== ===== ======",
13744
- "",
13745
- "Example 4. Specify compression method",
13746
- ""
13747
- ]
13748
- },
13749
- {
13750
- "type": "code",
13751
- "language": "console",
13752
- "value": [
13753
- "",
13754
- " $ db = database(\"dfs://demodb\", VALUE, 1..10)",
13755
- " $ t=table(take(1, 86400) as id, 2020.01.01T00:00:00 + 0..86399 as timestamp, rand(1..100, 86400) as val)",
13756
- " $ pt =db.createPartitionedTable(t, \"pt\", \"id\", {timestamp:\"delta\", val:\"delta\"})",
13757
- " $ pt.append!(t)",
13758
14007
  ""
13759
14008
  ]
13760
- },
13761
- {
13762
- "type": "text",
13763
- "value": [
13764
- ".. meta::",
13765
- " :keywords: in-memory table"
13766
- ]
13767
14009
  }
13768
14010
  ]
13769
14011
  }
@@ -23567,14 +23809,14 @@
23567
23809
  ]
23568
23810
  },
23569
23811
  {
23570
- "title": "note",
23812
+ "title": "Note",
23571
23813
  "children": [
23572
23814
  {
23573
23815
  "type": "text",
23574
23816
  "value": [
23575
- "If manually restart the server, please write the cache data into disk before killing the process.",
23817
+ "If manually restart the server, write the cache data into disk before killing the process.",
23576
23818
  "",
23577
- "If flushMode=0, smoe data may be lost after crash."
23819
+ "If flushMode=0, some data may be lost after crash."
23578
23820
  ]
23579
23821
  }
23580
23822
  ]
@@ -44078,7 +44320,7 @@
44078
44320
  {
44079
44321
  "type": "text",
44080
44322
  "value": [
44081
- "Calculate the moving linear regression for *X*. Return a tuple with 2 elements, alpha (the linear regression slope *LINEARREG_SLOPE*) and beta(the Linear regression intercept *LINEARREG_INTERCEPT*)."
44323
+ "Calculate the moving linear regression for *X*. Return a tuple with 2 elements, alpha (the Linear regression intercept *LINEARREG_INTERCEPT*) and beta (the linear regression slope *LINEARREG_SLOPE*)."
44082
44324
  ]
44083
44325
  }
44084
44326
  ]
@@ -47975,7 +48217,7 @@
47975
48217
  {
47976
48218
  "type": "text",
47977
48219
  "value": [
47978
- "mad(X)"
48220
+ "mad(X, [useMedian=false])"
47979
48221
  ]
47980
48222
  }
47981
48223
  ]
@@ -47987,7 +48229,9 @@
47987
48229
  {
47988
48230
  "type": "text",
47989
48231
  "value": [
47990
- "`X` is a vector or a matrix."
48232
+ "`X` is a vector, matrix or table.",
48233
+ "",
48234
+ "`useMedian` is a Boolean value indicating whether the result is generated with the median absolute deviation or the mean absolute deviation. The default value is false and it returns the mean absolute deviation."
47991
48235
  ]
47992
48236
  }
47993
48237
  ]
@@ -47999,9 +48243,11 @@
47999
48243
  {
48000
48244
  "type": "text",
48001
48245
  "value": [
48002
- "If *X* is a vector, return the mean absolute deviation of *X*.",
48246
+ "If *X* is a vector, return the average absolute deviation of *X*.",
48003
48247
  "",
48004
- "If *X* is a matrix, calculate the mean absolute deviation of each column of *X* and return a vector.",
48248
+ "If *X* is a matrix, the calculation is based on each column and returns a matrix.",
48249
+ "",
48250
+ "If *X* is a table, the calculation is based on each column and returns a table.",
48005
48251
  "",
48006
48252
  "As with all aggregate functions, NULL values are not included in the calculation."
48007
48253
  ]
@@ -48017,7 +48263,7 @@
48017
48263
  "language": "console",
48018
48264
  "value": [
48019
48265
  "",
48020
- " $ mad([85,90,95,NULL]);",
48266
+ " $ mad([85, 90, 95, NULL]);",
48021
48267
  " 3.333333333333333",
48022
48268
  "",
48023
48269
  " $ m=matrix(85 90 95, 185 190 195);",
@@ -48044,7 +48290,17 @@
48044
48290
  "value": [
48045
48291
  "",
48046
48292
  " $ mad m;",
48047
- " [3.333333333333333,3.333333333333333]"
48293
+ " [3.333333333333333, 3.333333333333333]",
48294
+ " ",
48295
+ " $ mad([0, 19.618568, 67.900707, 71.65218, 73.103952, 58.275308, 18.819054, 36.940571, 48.114366], false) ",
48296
+ " 22.204817",
48297
+ ""
48298
+ ]
48299
+ },
48300
+ {
48301
+ "type": "text",
48302
+ "value": [
48303
+ "Related function: :doc:`mmad`"
48048
48304
  ]
48049
48305
  }
48050
48306
  ]
@@ -66306,6 +66562,193 @@
66306
66562
  }
66307
66563
  ]
66308
66564
  },
66565
+ "regroup": {
66566
+ "title": "regroup",
66567
+ "type": "function",
66568
+ "children": [
66569
+ {
66570
+ "title": "Syntax",
66571
+ "type": "grammer",
66572
+ "children": [
66573
+ {
66574
+ "type": "text",
66575
+ "value": [
66576
+ "regroup(X, label, func, [byRow=true])"
66577
+ ]
66578
+ }
66579
+ ]
66580
+ },
66581
+ {
66582
+ "title": "Arguments",
66583
+ "type": "parameters",
66584
+ "children": [
66585
+ {
66586
+ "type": "text",
66587
+ "value": [
66588
+ "`X` is a matrix.",
66589
+ "",
66590
+ "`label` is a vector indicating the column/row labels based on which the matrix is grouped and aggregated. When *byRow* = true, the length of label must match the number of rows of *X*. Otherwise, it must match the number of columns of *X*.",
66591
+ "",
66592
+ "`func` is a unary aggregate function called on each group of the matrix. It can be built-in or user-defined.",
66593
+ "",
66594
+ "`byRow` is a Boolean. The default value is true, indicating that the matrix will be grouped and aggregated by rows. False means to group and aggregate matrix by columns. "
66595
+ ]
66596
+ }
66597
+ ]
66598
+ },
66599
+ {
66600
+ "title": "Details",
66601
+ "type": "detail",
66602
+ "children": [
66603
+ {
66604
+ "type": "text",
66605
+ "value": [
66606
+ "Group the data of a matrix based on user-specified column/row labels and apply aggregation on each group.",
66607
+ "",
66608
+ "``regroup`` is similar to the SQL keyword \"group by\", except that \"group by\" is applied only on *tables* whereas this function is applied on *matrices*. ",
66609
+ "",
66610
+ "Note: It is recommended that the *func* parameter be specified as a built-in aggregate function as built-in functions are optimized internally for optimal performance. (see Example 2)"
66611
+ ]
66612
+ }
66613
+ ]
66614
+ },
66615
+ {
66616
+ "title": "Examples",
66617
+ "type": "example",
66618
+ "children": [
66619
+ {
66620
+ "type": "text",
66621
+ "value": [
66622
+ "Example 1. Perform grouped aggregation on a matrix by row/column labels.",
66623
+ ""
66624
+ ]
66625
+ },
66626
+ {
66627
+ "type": "code",
66628
+ "language": "console",
66629
+ "value": [
66630
+ "",
66631
+ " $ m = rand(20, 4:5)",
66632
+ " $ m;",
66633
+ ""
66634
+ ]
66635
+ },
66636
+ {
66637
+ "type": "text",
66638
+ "value": [
66639
+ "+------+------+------+------+------+",
66640
+ "| col1 | col2 | col3 | col4 | col5 |",
66641
+ "+======+======+======+======+======+",
66642
+ "| 11 | 6 | 6 | 10 | 4 |",
66643
+ "+------+------+------+------+------+",
66644
+ "| 6 | 7 | 5 | 2 | 16 |",
66645
+ "+------+------+------+------+------+",
66646
+ "| 2 | 16 | 14 | 19 | 9 |",
66647
+ "+------+------+------+------+------+",
66648
+ "| 17 | 6 | 13 | 10 | 2 |",
66649
+ "+------+------+------+------+------+",
66650
+ "",
66651
+ ""
66652
+ ]
66653
+ },
66654
+ {
66655
+ "type": "code",
66656
+ "language": "console",
66657
+ "value": [
66658
+ "",
66659
+ " // by column labels",
66660
+ " $ label = `A`A`B`A`B",
66661
+ " $ regroup(X=m, label=label, func=firstNot, byRow=false)",
66662
+ ""
66663
+ ]
66664
+ },
66665
+ {
66666
+ "type": "text",
66667
+ "value": [
66668
+ "+-----+-----+",
66669
+ "| A | B |",
66670
+ "+=====+=====+",
66671
+ "| 11 | 6 |",
66672
+ "+-----+-----+",
66673
+ "| 6 | 5 |",
66674
+ "+-----+-----+",
66675
+ "| 2 | 14 |",
66676
+ "+-----+-----+",
66677
+ "| 17 | 13 |",
66678
+ "+-----+-----+",
66679
+ "",
66680
+ ""
66681
+ ]
66682
+ },
66683
+ {
66684
+ "type": "code",
66685
+ "language": "console",
66686
+ "value": [
66687
+ "",
66688
+ " // by row labels",
66689
+ " $ label = 1 2 1 2",
66690
+ " $ regroup(X=m, label=label, func=firstNot, byRow=true)",
66691
+ ""
66692
+ ]
66693
+ },
66694
+ {
66695
+ "type": "text",
66696
+ "value": [
66697
+ "+-------+------+------+------+------+------+",
66698
+ "| label | col1 | col2 | col3 | col4 | col5 |",
66699
+ "+=======+======+======+======+======+======+",
66700
+ "| 1 | 11 | 6 | 6 | 10 | 4 |",
66701
+ "+-------+------+------+------+------+------+",
66702
+ "| 2 | 6 | 7 | 5 | 2 | 16 |",
66703
+ "+-------+------+------+------+------+------+",
66704
+ "",
66705
+ " ",
66706
+ "Example 2. Compare the performance between applying a built-in function and a user-defined function.",
66707
+ ""
66708
+ ]
66709
+ },
66710
+ {
66711
+ "type": "code",
66712
+ "language": "console",
66713
+ "value": [
66714
+ "",
66715
+ " $ m = rand(1000.0, 10000)$100:100",
66716
+ " $ defg my_avg(v):avg(v)",
66717
+ "",
66718
+ " $ timer(1000) regroup(m, take(1 2 3 4 5, 100), avg)",
66719
+ " Time elapsed: 176.175 ms",
66720
+ "",
66721
+ " $ timer(1000) regroup(m, take(1 2 3 4 5, 100), my_avg)",
66722
+ " Time elapsed: 1062.553 ms",
66723
+ "",
66724
+ ""
66725
+ ]
66726
+ },
66727
+ {
66728
+ "type": "text",
66729
+ "value": [
66730
+ "Example 3. Aggregate the panel data by minute ",
66731
+ ""
66732
+ ]
66733
+ },
66734
+ {
66735
+ "type": "code",
66736
+ "language": "console",
66737
+ "value": [
66738
+ "",
66739
+ " $ n=1000",
66740
+ " $ timestamp = 09:00:00 + rand(10000, n).sort!()",
66741
+ " $ id = take(`st1`st2`st3, n)",
66742
+ " $ vol = 100 + rand(10.0, n)",
66743
+ " $ vt = table(timestamp, id, vol)",
66744
+ " $ m = exec vol from vt pivot by timestamp, id",
66745
+ " $ regroup(m, minute(m.rowNames()), avg)"
66746
+ ]
66747
+ }
66748
+ ]
66749
+ }
66750
+ ]
66751
+ },
66309
66752
  "remoteRun": {
66310
66753
  "title": "remoteRun",
66311
66754
  "type": "function",