<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_type(self, dtype: type, *cols, **kwargs):
 """ Convert colums values to a given type in the main dataframe :param dtype: a type to convert to: ex: ``str`` :type dtype: type :param \*cols: names of the colums :type \*cols: str, at least one :param \*\*kwargs: keyword arguments for ``df.astype`` :type \*\*kwargs: optional :example: ``ds.to_type(str, "mycol")`` """

        try:
            allcols = self.df.columns.values
            for col in cols:
                if col not in allcols:
                    self.err("Column " + col + " not found")
                    return
                self.df[col] = self.df[col].astype(dtype, **kwargs)
        except Exception as e:
            self.err(e, "Can not convert to type")