# set_role¶

DataFrame.set_role(cols, role, time_formats=None)[source]

Assigns a new role to one or more columns.

When switching from a role based on type float to a role based on type string or vice verse, an implicit type conversion will be conducted. The time_formats argument is used to interpret time format string. For more information on roles, please refer to the user guide.

Args:
columns (str, FloatColumn, StringColumn, or List[str, FloatColumn, StringColumn]):

The columns or the names of the columns.

role (str):

The role to be assigned.

time_formats (str or List[str], optional):

Formats to be used to parse the time stamps. This is only necessary, if an implicit conversion from a StringColumn to a time stamp is taking place.

Example:
data_df = dict(
animal=["hawk", "parrot", "goose"],
date=["04/06/2019", "01/03/2019", "24/12/2018"])
df = getml.DataFrame.from_dict(data_df, "animal_elections")
df.set_role(['animal'], getml.data.roles.categorical)

| date                        | animal      | votes     |