shapelets.DataSet.select_columns#

DataSet.select_columns(cols: Optional[Union[str, int, List[Union[int, str]]]] = None, pattern: Optional[str] = None, full_match: bool = True, flags: RegexFlag = RegexFlag.IGNORECASE) DataSet#

Selects or reorganises columns in a DataSet

Parameters:
cols: string, int or a list of strings and/or ints

The selected columns, either by index or by name, will be ordered by this list.

pattern: string or regular expression

Selects all columns matching a regular expression. The order of the columns will the the same as the current dataset.

full_match: boolean, defaults to True

When pattern is given, this flag indicates if re.fullmatch should be used to determine if a column is to be dropped; otherwise, the method re.match will be used.

flags: re.RegexFlag, defaults to IGNORECASE

Flags to be used when compiling the pattern.

Returns:
DataSet

A new DataSet instance.

Note

It is possible to specify cols and pattern simultaneously; in this scenario, columns selected by cols will take preference over the selection produced by the regular expression.

Examples

Select specific columns

>>> df.select_columns(['mycol1','MyCol2','Mycol3'])

Filter all columns starting with string “mycol” followed by a number

>>> df.select_columns(pattern=r'\b(mycol)\d+')