Commit e678a1d
Add set_xindex and drop_indexes methods (#6971)
* temporary API to set custom indexes
* add the temporary index API to DataArray
* add options argument to Index.from_variables()
It allows passing options to the constructor of a custom index class (if
any).
The **options arguments of Dataset.set_xindex() are passed through.
Also add type annotations to set_xindex().
* fix mypy
* remove temporary API warning
* add the Index class in Xarray's root namespace
* improve set_xindex docstrings and add to api.rst
* remove temp comments
* special case for pandas multi-index dim coord
* add tests for set_xindex
* error message tweaks
* set_xindex with 1 coord: avoid reodering coords
* mypy fixes
* add Dataset and DataArray drop_indexes methods
* improve assert_no_index_corrupted error msg
* drop_indexes: add tests
* add drop_indexes to api.rst
* improve docstrings of legacy methods
* add what's new entry
* try using correct typing w/o mypy complaining
* make index_cls arg optional
Try setting a pandas (multi-)index by default.
* docstrings fixes and tweaks
* make Index.from_variables options arg keyword only
* improve set_xindex invalid coordinates error msg
* add xarray.indexes namespace
* type tweaks
Co-authored-by: Keewis <[email protected]>1 parent 2f0f95a commit e678a1d
File tree
9 files changed
+415
-18
lines changed- doc
- xarray
- core
- indexes
- tests
9 files changed
+415
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| |||
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| 150 | + | |
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
| |||
298 | 300 | | |
299 | 301 | | |
300 | 302 | | |
| 303 | + | |
301 | 304 | | |
302 | 305 | | |
303 | 306 | | |
| |||
330 | 333 | | |
331 | 334 | | |
332 | 335 | | |
| 336 | + | |
333 | 337 | | |
334 | 338 | | |
335 | 339 | | |
| |||
1080 | 1084 | | |
1081 | 1085 | | |
1082 | 1086 | | |
| 1087 | + | |
1083 | 1088 | | |
1084 | 1089 | | |
1085 | 1090 | | |
1086 | 1091 | | |
1087 | 1092 | | |
1088 | 1093 | | |
1089 | 1094 | | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
1090 | 1100 | | |
1091 | 1101 | | |
1092 | 1102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2349 | 2349 | | |
2350 | 2350 | | |
2351 | 2351 | | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
2352 | 2357 | | |
2353 | 2358 | | |
2354 | 2359 | | |
| |||
2393 | 2398 | | |
2394 | 2399 | | |
2395 | 2400 | | |
| 2401 | + | |
2396 | 2402 | | |
2397 | 2403 | | |
2398 | 2404 | | |
| |||
2406 | 2412 | | |
2407 | 2413 | | |
2408 | 2414 | | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
2409 | 2421 | | |
2410 | 2422 | | |
2411 | 2423 | | |
| |||
2424 | 2436 | | |
2425 | 2437 | | |
2426 | 2438 | | |
| 2439 | + | |
| 2440 | + | |
2427 | 2441 | | |
2428 | 2442 | | |
2429 | 2443 | | |
2430 | 2444 | | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
2431 | 2474 | | |
2432 | 2475 | | |
2433 | 2476 | | |
| |||
2738 | 2781 | | |
2739 | 2782 | | |
2740 | 2783 | | |
| 2784 | + | |
| 2785 | + | |
| 2786 | + | |
| 2787 | + | |
| 2788 | + | |
| 2789 | + | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
| 2793 | + | |
| 2794 | + | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
2741 | 2809 | | |
2742 | 2810 | | |
2743 | 2811 | | |
| |||
0 commit comments