interpret_column_selection#

Survey.interpret_column_selection(column_selection: str | int | list | ndarray | Series | range | Callable[[SurveyVariable], bool] | None)#

Interpret different ways to select a subset of columns (or variables).

Parameters#

column_selection: str, int, list, np.ndarray, pandas.Series, range, QuestionSelector or None

A specification of a selection of columns. The result is obtained in the following way:

  • if column_selection is None, the function chooses all columns of the survey.

  • if column_selection is a single integer, the function chooses the single column with this index.

  • if column_selection is a single string, the function chooses the single column with this name.

  • if column_selection is something arraylike, the function does the same as for single values, but for every value in the list.

  • if column_selection is a QuestionSelector (a Callable[[SurveyVariable], bool]), the QuestionSelector is called for every SurveyVariable object and the SurveyVariable is selected if QuestionSelector returns True.

Returns#

list

A selection of column names (i.e. variable names).