Skip to content

Commit 374875b

Browse files
authored
Merge pull request #175 from datarian/fix-tests-with-new-col-na_categorical
Fix tests with new col na categorical
2 parents 325a570 + 34ca468 commit 374875b

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ env:
1414
- MODULE=category_encoders
1515
matrix:
1616
# The versions should match the minimal requirements in requirements.txt and setup.py
17-
- DISTRIB="conda" PYTHON_VERSION="2.7" CYTHON_VERSION="0.21"
18-
NUMPY_VERSION="1.11.1" PANDAS_VERSION="0.21.1" PATSY_VERSION="0.4.1"
19-
SCIKIT_VERSION="0.20.2" SCIPY_VERSION="0.17.0" STATSMODELS_VERSION="0.6.1"
20-
- DISTRIB="conda" PYTHON_VERSION="3.5" COVERAGE="true" CYTHON_VERSION="0.23.4"
21-
NUMPY_VERSION="1.11.1" PANDAS_VERSION="0.21.1" PATSY_VERSION="0.4.1"
22-
SCIKIT_VERSION="0.17.1" SCIPY_VERSION="0.17.0" STATSMODELS_VERSION="0.6.1"
17+
- DISTRIB="conda" PYTHON_VERSION="2.7" CYTHON_VERSION="0.23.5"
18+
NUMPY_VERSION="1.11.3" PANDAS_VERSION="0.21.1" PATSY_VERSION="0.4.1"
19+
SCIKIT_VERSION="0.20.0" SCIPY_VERSION="0.19.0" STATSMODELS_VERSION="0.6.1"
20+
- DISTRIB="conda" PYTHON_VERSION="3.6" COVERAGE="true" CYTHON_VERSION="0.25.2"
21+
NUMPY_VERSION="1.11.3" PANDAS_VERSION="0.21.1" PATSY_VERSION="0.4.1"
22+
SCIKIT_VERSION="0.20.0" SCIPY_VERSION="0.19.0" STATSMODELS_VERSION="0.6.1"
2323

2424
install: source ci_scripts/install.sh
2525
script: bash ci_scripts/test.sh

category_encoders/basen.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,21 +349,20 @@ def basen_to_integer(self, X, cols, base):
349349
-------
350350
numerical: DataFrame
351351
"""
352-
out_cols = X.columns.values
352+
out_cols = X.columns.values.tolist()
353353

354354
for col in cols:
355355
col_list = [col0 for col0 in out_cols if str(col0).startswith(str(col))]
356+
insert_at = out_cols.index(col_list[0])
356357

357358
if base == 1:
358359
value_array = np.array([int(col0.split('_')[-1]) for col0 in col_list])
359360
else:
360361
len0 = len(col_list)
361362
value_array = np.array([base ** (len0 - 1 - i) for i in range(len0)])
362-
363-
X[col] = np.dot(X[col_list].values, value_array.T)
364-
out_cols = [col0 for col0 in out_cols if col0 not in col_list]
365-
366-
X = X.reindex(columns=out_cols + cols)
363+
X.insert(insert_at,col,np.dot(X[col_list].values, value_array.T))
364+
X.drop(col_list, axis=1, inplace=True)
365+
out_cols = X.columns.values.tolist()
367366

368367
return X
369368

category_encoders/tests/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def create_dataset(n_rows=1000, extras=False, has_none=True):
5050
random.choice(['A', 'B', 'C', np.nan]) # Categorical with missing values
5151
] for row in range(n_rows)]
5252

53-
df = pd.DataFrame(ds, columns=['float', 'float_edge', 'unique_int', 'unique_str', 'invariant', 'underscore', 'none', 'extra', 321, 'categorical', 'categorical_na'])
53+
df = pd.DataFrame(ds, columns=['float', 'float_edge', 'unique_int', 'unique_str', 'invariant', 'underscore', 'none', 'extra', 321, 'categorical', 'na_categorical'])
5454
df['categorical'] = pd.Categorical(df['categorical'], categories=['A', 'B', 'C'])
55-
df['categorical_na'] = pd.Categorical(df['categorical_na'], categories=['A', 'B', 'C'])
55+
df['na_categorical'] = pd.Categorical(df['na_categorical'], categories=['A', 'B', 'C'])
5656
return df
5757

5858

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
numpy>=1.11.1
2-
scikit-learn>=0.20.2
3-
scipy>=0.17.0
1+
numpy>=1.11.3
2+
scikit-learn>=0.20.0
3+
scipy>=0.19.0
44
statsmodels>=0.6.1
55
pandas>=0.21.1
66
patsy>=0.4.1

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
include_package_data=True,
3030
author='Will McGinnis',
3131
install_requires=[
32-
'numpy>=1.11.1',
33-
'scikit-learn>=0.20.2',
34-
'scipy>=0.17.0',
32+
'numpy>=1.11.3',
33+
'scikit-learn>=0.20.0',
34+
'scipy>=0.19.0',
3535
'statsmodels>=0.6.1',
3636
'pandas>=0.21.1',
3737
'patsy>=0.4.1',

0 commit comments

Comments
 (0)