adb2f55d8629b588bba17a5232946b2245c157fc,tests/test_preprocessing.py,,encoded_data,#Any#,32
Before Change
def encoded_data(data):
dat_cat = data.select_dtypes(include=["category"])
expected_cat = {}
for nam, col in dat_cat.iteritems():
for cat in col.cat.categories[1:]:
expected_cat["{}={}".format(nam, cat)] = pd.Series(
col == cat, dtype=np.float64)
expected_cat = pd.DataFrame(expected_cat)
expected_data = pd.concat((data.drop(dat_cat, axis=1), expected_cat), axis=1)
return expected_data
class TestOneHotEncoder(TestCase):
After Change
def encoded_data(data):
expected = []
for nam, col in data.iteritems():
if hasattr(col, "cat"):
for cat in col.cat.categories[1:]:
name = "{}={}".format(nam, cat)
s = pd.Series(col == cat, dtype=np.float64)
expected.append((name, s))
else:
expected.append((nam, col))
expected_data = pd.DataFrame.from_items(expected)
return expected_data
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances
Project Name: sebp/scikit-survival
Commit Name: adb2f55d8629b588bba17a5232946b2245c157fc
Time: 2017-07-23
Author: sebp@k-d-w.org
File Name: tests/test_preprocessing.py
Class Name:
Method Name: encoded_data
Project Name: HDI-Project/ATM
Commit Name: dea98f8e7c2e6c5e37ffb81bc2f52f386bb99a3e
Time: 2017-12-21
Author: bcyphers@mit.edu
File Name: atm/encoder.py
Class Name: DataEncoder
Method Name: transform
Project Name: tyarkoni/pliers
Commit Name: 9d478d351665502019ac40a7302e769b9d3f6660
Time: 2018-04-17
Author: quinten.mcnamara@gmail.com
File Name: pliers/extractors/api/google.py
Class Name: GoogleVideoIntelligenceAPIExtractor
Method Name: _to_df