Selecting columns

Some signals return multiple time series and you may only be interested in some of them. This is relevant for entity-independent signals that return multiple time series, and for entity-dependent signals that return multiple time series per entity. In these cases the different time series have different names, and these can be used to select the time series you are interested in.

Exact match

You can select time series by specifying the full name of the time series inside square brackets. Multiple columns are selected by providing a tuple of strings. The selection is case insensitive.

Examples

Select the beta column of the underlying signal:

my_signal['beta']

Select both the alpha and beta columns:

my_signal[('alpha', 'beta')]

Select a specific segment after following a relationship:

graph_signal('signal', ['ns.HAS_SEGMENT'])['Americas']

Substring and regex filtering

Alternatively you can select columns with the filter_columns method, which matches columns based on a substring or regex search.

signal.filter_columns(pattern: str, *, case: bool = True, regex: bool = True)
Parameters
  • pattern – The pattern to search for.

  • case – Whether the search is case sensitive.

  • regex – Whether the pattern is treated as a regular expression

Examples

Select all columns that contain the substring beta:

my_signal.filter_columns('beta')

Select all columns that contain the substring beta regardless of case (e.g. BETA or BeTa):

my_signal.filter_columns('beta', case=False)

Select all columns that contain either alpha or beta:

my_signal.filter_columns('alpha|beta')

Select all columns that contain the character | (since it has a special meaning in regular expressions, regex search must be disabled):

my_signal.filter_columns('|', regex=False)