The cols_align() method sets the alignment of one or more columns. The align argument can be set to one of "left", "center", or "right" and the columns argument can be used to specify which columns to apply the alignment to. If columns is not specified, the alignment is applied to all columns.
Parameters
Name
Type
Description
Default
align
str
The alignment to apply. Must be one of "left", "center", or "right".
'left'
columns
SelectExpr
The columns to target. Can either be a single column name or a series of column names provided in a list. If None, the alignment is applied to all columns.
The GT object is returned. This is the same object that the method is called on so that we can facilitate method chaining.
Examples
Let’s use the countrypops to create a small table. We can change the alignment of the population column with cols_align(). In this example, the column label and body cells of population will be aligned to the left.