with_role¶
- DataFrame.with_role(cols, role, time_formats=None)[source]¶
Returns a new
View
with modified roles.The difference between
with_role()
andset_role()
is thatwith_role()
returns a view that is lazily evaluated when needed whereasset_role()
is an in-place operation. From a memory perspective, in-place operations likeset_role()
are preferable.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:
- cols (str, FloatColumn, StingColumn, or List[str, FloatColumn, StringColumn]):
The columns or the names thereof.
- 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.