human
I am working on the file "CapstoneSEER/SEER Data Analysis Phase 2- Wrangling.ipynb".
The first task is:
Last, we use the one-hot-encode procedure to return a new dataframe with vectorized data. We use this function only when we want to call standard distance metrics (such as k-nearest neighbors) for catagorical variables (e.g. race). See this link to learn more: http://stackoverflow.com/questions/17469835/one-hot-encoding-for-machine-learning
Can you write Python code for it?

=====
What is a the Python code you requested?
assistant
#Here is the Python code you requested.

     def one_hot_data(self, data, cols):
       
        # check to only encode columns that are in the data
        col_to_process = [c for c in cols if c in data]
        return pd.get_dummies(data, columns = col_to_process,  prefix = col_to_process)