Commit 8003f07
Fix CategoricalMethodsMixin for narwhals-returning check_X
After the rebase onto narwhals-migration, check_X / check_X_y return a
narwhals frame. The previous "Update base_encoder.py" left the method
bodies referencing a local nw_X that no longer exists.
- _encode / _check_nan_values_after_transformation: use the narwhals
frame that is actually passed in (was NameError on nw_X).
- _check_nan_values_after_transformation now assumes a narwhals frame
(its only caller, _encode, hands it one); no nw.from_native round-trip.
- _get_feature_names_in: single branch-free `list(X.columns)` (normalises
a narwhals column list and a pandas Index alike).
- _check_transform_input_and_state keeps the native X for the
column-count check and returns the narwhals frame.
- Drop now-unused narwhals imports; refresh docstrings.
- test_categorical_method_mixin: pass a narwhals frame to the two direct
_check_nan_values_after_transformation calls.
The encoder subclasses still run pandas-only fit()/transform() code and
are adapted in their own migration PRs.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent 5c3a55b commit 8003f07
2 files changed
Lines changed: 31 additions & 21 deletions
File tree
- feature_engine/encoding
- tests/test_encoding/test_base_encoders
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
| |||
163 | 161 | | |
164 | 162 | | |
165 | 163 | | |
166 | | - | |
| 164 | + | |
167 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
168 | 171 | | |
169 | | - | |
170 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
171 | 175 | | |
172 | 176 | | |
173 | 177 | | |
174 | 178 | | |
175 | 179 | | |
176 | 180 | | |
177 | 181 | | |
178 | | - | |
| 182 | + | |
179 | 183 | | |
180 | 184 | | |
181 | 185 | | |
182 | 186 | | |
| 187 | + | |
183 | 188 | | |
184 | 189 | | |
185 | 190 | | |
186 | 191 | | |
187 | 192 | | |
188 | 193 | | |
189 | | - | |
190 | | - | |
| 194 | + | |
191 | 195 | | |
192 | 196 | | |
193 | 197 | | |
194 | | - | |
195 | | - | |
| 198 | + | |
| 199 | + | |
196 | 200 | | |
197 | 201 | | |
198 | 202 | | |
199 | 203 | | |
200 | 204 | | |
201 | | - | |
| 205 | + | |
| 206 | + | |
202 | 207 | | |
203 | 208 | | |
204 | 209 | | |
| |||
231 | 236 | | |
232 | 237 | | |
233 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
234 | 245 | | |
235 | 246 | | |
236 | | - | |
| 247 | + | |
237 | 248 | | |
238 | 249 | | |
239 | | - | |
| 250 | + | |
240 | 251 | | |
241 | 252 | | |
242 | 253 | | |
243 | 254 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | 255 | | |
249 | | - | |
| 256 | + | |
250 | 257 | | |
| 258 | + | |
| 259 | + | |
251 | 260 | | |
252 | 261 | | |
253 | 262 | | |
254 | 263 | | |
255 | | - | |
| 264 | + | |
256 | 265 | | |
257 | 266 | | |
258 | 267 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
125 | | - | |
| 126 | + | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| |||
0 commit comments