Tabulate
insert a DataFrame as a worksheet Table
Calling Sequence
Parameters
Description
Examples
Compatibility
Tabulate(df, opts)
df
-
a DataFrame object
opts
options for the DocumentTools[Tabulate] command, as described on that help page
The Tabulate command, applied to a DataFrame object, inserts the DataFrame as a worksheet Table into the worksheet.
The column labels are shown in a row inserted before the rows of actual data in the DataFrame. Similarly, the row labels are shown in a column inserted before the columns of data. By default, they are shown with a different background color than the other values.
The options for this command are discussed on the help page DocumentTools[Tabulate]. They include options for changing the foreground and background color for the cells, showing table borders, as well as options to control the width of the table and of the individual columns.
The return value of the command is the identity of the inserted parent Table, as a string. The display of the returned value can be suppressed by terminating the statement with a full colon.
This command inserts the assembly of Tables and Embedded Components into the worksheet using the InsertContent facility. The inserted content is placed after any usual output of the Execution Group in which this command is called. Each Execution Group allows for only one inserted result to exist at any given time. Multiple calls to commands which utilize the InsertContent facility made within the same Execution Group will result in each successive inserted assembly replacing any assembly inserted earlier for that Execution Group.
A basic example follows:
df≔DataFrame⁡1,2|3,4|5,6,columns=a,b,c,rows=d,e
df≔
Tabulate⁡df:
a
b
c
d
1
3
5
e
2
4
6
If we want to specify the relative width of the columns, we can do that by specifying the weights option, which specifies relative weights for the widths of the table columns. Note that, while the DataFrame has three columns, the Table has four: there is an extra column for the row labels. Thus, we specify four weights. We also use the width option to specify that the total width of the table should be 50% of the width of the worksheet.
Tabulate⁡df,weights=1,2,2,2,width=50.:
The returned identity of the Table can be used to modify Table properties following insertion.
id≔Tabulate⁡df,weights=1,2,2,2,width=50.:
id
Tabulate1
DocumentTools:-SetProperty⁡id,fillcolor2..,2..,LightGreen
The Tabulate command was introduced in Maple 2016.
For more information on Maple 2016 changes, see Updates in Maple 2016.
See Also
DataFrame
DocumentTools[Tabulate]
Download Help Document