9da9c8edd24bede6eeeeea8739835ea53ca58cbc,category_encoders/one_hot.py,OneHotEncoder,reverse_dummies,#OneHotEncoder#,293

Before Change


        out_cols = X.columns.values

        for col in cols:
            col_list = [col0 for col0 in out_cols if str(col0).startswith(str(col))]
            prefix_length = len(str(col))+1 // original column name plus underscore
            if self.use_cat_names:
                X[col] = 0
                for tran_col in col_list:
                    val = tran_col[prefix_length:]
                    X.loc[X[tran_col] == 1, col] = val
            else:
                value_array = np.array([int(col0[prefix_length:]) for col0 in col_list])
                X[col] = np.dot(X[col_list].values, value_array.T)
            out_cols = [col0 for col0 in out_cols if col0 not in col_list]

        X = X.reindex(columns=out_cols + cols)

After Change


                existing_col = column_mapping.get("new_col_name")
                val = column_mapping.get("val")
                X.loc[X[existing_col] == 1, col] = val
                mapped_columns.append(existing_col)

        out_cols = [col0 for col0 in out_cols if col0 not in mapped_columns]

        return X.reindex(columns=out_cols + cols)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 4

Instances


Project Name: scikit-learn-contrib/categorical-encoding
Commit Name: 9da9c8edd24bede6eeeeea8739835ea53ca58cbc
Time: 2018-10-21
Author: jcastaldo08@gmail.com
File Name: category_encoders/one_hot.py
Class Name: OneHotEncoder
Method Name: reverse_dummies


Project Name: PyMVPA/PyMVPA
Commit Name: c12606499df2c43104528c6019102d24af5c0eb8
Time: 2014-10-29
Author: michael.hanke@gmail.com
File Name: mvpa2/datasets/openfmri.py
Class Name: OpenFMRIDataset
Method Name: get_subj_ids


Project Name: geekcomputers/Python
Commit Name: e1c4e6a7c7db68e123d978bfc56feb057898935f
Time: 2019-10-24
Author: kostasdedesar@penguin
File Name: Counting-sort.py
Class Name:
Method Name:


Project Name: PyMVPA/PyMVPA
Commit Name: c12606499df2c43104528c6019102d24af5c0eb8
Time: 2014-10-29
Author: michael.hanke@gmail.com
File Name: mvpa2/datasets/openfmri.py
Class Name: OpenFMRIDataset
Method Name: get_bold_run_ids