Commit 904aa7d
Pandas: Upgrade to 3.0 and fix compatibility issues (#4838)
Summary:
Pandas 3.0 introduces several breaking changes (https://pandas.pydata.org/docs/whatsnew/v3.0.0.html#other-api-changes) that required fixes across the codebase:
1. StringDtype inference: Pandas 3.0 infers string columns to use StringDtype instead of object dtype. This breaks DataFrame comparisons since our Data class expects object dtype (defined in COLUMN_DATA_TYPES). Fixed by setting `pd.options.future.infer_string = False` in modules that construct DataFrames.
2. Deprecated inplace on replace(): The `inplace=True` parameter on Series.replace() is deprecated. Changed to assignment pattern: `df["col"] = df["col"].replace(...)`.
3. read_json() no longer accepts strings: pd.read_json() now requires file paths or file-like objects, not raw JSON strings. Wrapped JSON strings with StringIO().
4. Read-only arrays from DataFrame.to_numpy(): Arrays returned by to_numpy() are now read-only views. Added .copy() before passing to torch.from_numpy() which requires writable arrays.
5. Test dtype mismatches: Tests comparing DataFrames failed because manually constructed expected DataFrames had different dtypes than production code. Fixed by wrapping expected DataFrames with Data(df=...).df to ensure consistent dtype casting.
Pull Request resolved: #4838
Reviewed By: mgrange1998
Differential Revision: D91825190
Pulled By: CristianLara
fbshipit-source-id: 242e097f1f3c90c4c9bb18cb7dc68ea4609adecd1 parent 2ea3fd1 commit 904aa7d
File tree
14 files changed
+302
-217
lines changed- ax
- adapter
- tests
- transforms/tests
- api/tests
- core
- tests
- metrics/tests
- service/utils
- storage/sqa_store
14 files changed
+302
-217
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
351 | 353 | | |
352 | 354 | | |
353 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
354 | 382 | | |
355 | 383 | | |
356 | 384 | | |
| |||
383 | 411 | | |
384 | 412 | | |
385 | 413 | | |
| 414 | + | |
386 | 415 | | |
387 | 416 | | |
388 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| 104 | + | |
100 | 105 | | |
101 | 106 | | |
102 | 107 | | |
| |||
248 | 253 | | |
249 | 254 | | |
250 | 255 | | |
| 256 | + | |
251 | 257 | | |
252 | 258 | | |
253 | 259 | | |
| |||
261 | 267 | | |
262 | 268 | | |
263 | 269 | | |
264 | | - | |
| 270 | + | |
| 271 | + | |
265 | 272 | | |
266 | 273 | | |
267 | 274 | | |
| |||
359 | 366 | | |
360 | 367 | | |
361 | 368 | | |
| 369 | + | |
362 | 370 | | |
363 | 371 | | |
364 | 372 | | |
| |||
467 | 475 | | |
468 | 476 | | |
469 | 477 | | |
| 478 | + | |
470 | 479 | | |
471 | 480 | | |
472 | 481 | | |
| |||
522 | 531 | | |
523 | 532 | | |
524 | 533 | | |
525 | | - | |
| 534 | + | |
526 | 535 | | |
527 | 536 | | |
528 | 537 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
449 | 453 | | |
450 | 454 | | |
451 | 455 | | |
| 456 | + | |
452 | 457 | | |
453 | 458 | | |
454 | 459 | | |
| |||
495 | 500 | | |
496 | 501 | | |
497 | 502 | | |
| 503 | + | |
498 | 504 | | |
499 | 505 | | |
500 | 506 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| 261 | + | |
261 | 262 | | |
262 | 263 | | |
263 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| |||
0 commit comments