Commit 0165d14
committed
CLN/DOC/TST: Categorical fixups (GH7768)
Categorical: preserve ints when NaN are present
`Categorical([1, np.nan])` would end up with a single `1.` float level.
This commit ensures that if `values` is a list of ints and contains np.nan,
the float conversation does not take place.
Categorical: fix describe with np.nan
Categorical: ensure that one can assign np.nan
Categorical: fix assigning NaN if NaN in levels
API: change default Categorical.from_codes() to ordered=False
In the normal constructor `ordered=True` is only assumed if the levels
are given or the values are sortable (which is most of the cases), but
in `from_codes(...)` we can't asssume this so the default should be
`False`.
Categorical: add some links to Categorical in the other docs
Categorical: use s.values when calling private methods
s.values is the underlying Categorical object, s.cat will be changed
to only expose the API methods/properties.
Categorical: Change series.cat to only expose the API
Categorical: Fix order and na_position
Categorical: Fix comparison of Categoricals and Series|Categorical|np.array
Categorical can only be comapred to another Categorical with the same levels
and the same ordering or to a scalar value.
If the Categorical has no order defined (cat.ordered == False), only equal
(and not equal) are defined.
Categorical: Tab completition tests
Categorical: Fix for NA handling/float converting in levels
Categorical: make sure fillna gets both missing values and NA-levels
Categorical: add back labels as deprecated property
Categorical: Fix assigment to a Series(Categorical)) and remove Series.cat.codes
Categorical: declare most methods in Categorical NON-API1 parent 85ad2b7 commit 0165d14
File tree
12 files changed
+851
-130
lines changed- doc/source
- pandas
- core
- tests
12 files changed
+851
-130
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
635 | 636 | | |
636 | 637 | | |
637 | 638 | | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
638 | 665 | | |
639 | 666 | | |
640 | 667 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
| 524 | + | |
| 525 | + | |
528 | 526 | | |
529 | 527 | | |
530 | 528 | | |
531 | 529 | | |
532 | | - | |
533 | | - | |
534 | 530 | | |
535 | 531 | | |
536 | 532 | | |
537 | 533 | | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | 534 | | |
543 | | - | |
544 | | - | |
| 535 | + | |
545 | 536 | | |
546 | 537 | | |
547 | 538 | | |
548 | 539 | | |
549 | | - | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
550 | 543 | | |
551 | | - | |
552 | | - | |
| 544 | + | |
| 545 | + | |
553 | 546 | | |
554 | 547 | | |
555 | 548 | | |
556 | 549 | | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
| 550 | + | |
569 | 551 | | |
570 | 552 | | |
571 | 553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
331 | 332 | | |
332 | 333 | | |
333 | 334 | | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 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 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
334 | 386 | | |
335 | 387 | | |
336 | 388 | | |
| |||
489 | 541 | | |
490 | 542 | | |
491 | 543 | | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
498 | 550 | | |
499 | | - | |
500 | | - | |
| 551 | + | |
501 | 552 | | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
506 | 561 | | |
507 | 562 | | |
508 | 563 | | |
509 | 564 | | |
510 | 565 | | |
511 | 566 | | |
512 | | - | |
| 567 | + | |
| 568 | + | |
513 | 569 | | |
514 | 570 | | |
515 | 571 | | |
516 | 572 | | |
517 | 573 | | |
518 | 574 | | |
519 | | - | |
| 575 | + | |
520 | 576 | | |
521 | 577 | | |
522 | 578 | | |
| |||
548 | 604 | | |
549 | 605 | | |
550 | 606 | | |
551 | | - | |
| 607 | + | |
552 | 608 | | |
553 | 609 | | |
554 | 610 | | |
| |||
560 | 616 | | |
561 | 617 | | |
562 | 618 | | |
563 | | - | |
| 619 | + | |
564 | 620 | | |
565 | 621 | | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
566 | 638 | | |
567 | 639 | | |
568 | 640 | | |
| |||
579 | 651 | | |
580 | 652 | | |
581 | 653 | | |
582 | | - | |
| 654 | + | |
583 | 655 | | |
584 | 656 | | |
585 | 657 | | |
586 | 658 | | |
587 | 659 | | |
588 | 660 | | |
589 | 661 | | |
590 | | - | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
591 | 666 | | |
592 | 667 | | |
593 | 668 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
| 286 | + | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
| 289 | + | |
289 | 290 | | |
290 | 291 | | |
291 | 292 | | |
| |||
0 commit comments