@@ -334,11 +334,11 @@ def test_infer_dtype_bytes(self):
334
334
335
335
# string array of bytes
336
336
arr = np .array (list ('abc' ), dtype = 'S1' )
337
- assert lib .infer_dtype (arr , skipna = False ) == compare
337
+ assert lib .infer_dtype (arr , skipna = True ) == compare
338
338
339
339
# object array of bytes
340
340
arr = arr .astype (object )
341
- assert lib .infer_dtype (arr , skipna = False ) == compare
341
+ assert lib .infer_dtype (arr , skipna = True ) == compare
342
342
343
343
# object array of bytes with missing values
344
344
assert lib .infer_dtype ([b'a' , np .nan , b'c' ], skipna = True ) == compare
@@ -538,32 +538,40 @@ def test_length_zero(self, skipna):
538
538
539
539
def test_integers (self ):
540
540
arr = np .array ([1 , 2 , 3 , np .int64 (4 ), np .int32 (5 )], dtype = 'O' )
541
- result = lib .infer_dtype (arr , skipna = False )
541
+ result = lib .infer_dtype (arr , skipna = True )
542
542
assert result == 'integer'
543
543
544
544
arr = np .array ([1 , 2 , 3 , np .int64 (4 ), np .int32 (5 ), 'foo' ], dtype = 'O' )
545
- result = lib .infer_dtype (arr , skipna = False )
545
+ result = lib .infer_dtype (arr , skipna = True )
546
546
assert result == 'mixed-integer'
547
547
548
548
arr = np .array ([1 , 2 , 3 , 4 , 5 ], dtype = 'i4' )
549
- result = lib .infer_dtype (arr , skipna = False )
549
+ result = lib .infer_dtype (arr , skipna = True )
550
550
assert result == 'integer'
551
551
552
+ def test_deprecation (self ):
553
+ # GH 24050
554
+ arr = np .array ([1 , 2 , 3 ], dtype = object )
555
+
556
+ with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ):
557
+ result = lib .infer_dtype (arr ) # default: skipna=None -> warn
558
+ assert result == 'integer'
559
+
552
560
def test_bools (self ):
553
561
arr = np .array ([True , False , True , True , True ], dtype = 'O' )
554
- result = lib .infer_dtype (arr , skipna = False )
562
+ result = lib .infer_dtype (arr , skipna = True )
555
563
assert result == 'boolean'
556
564
557
565
arr = np .array ([np .bool_ (True ), np .bool_ (False )], dtype = 'O' )
558
- result = lib .infer_dtype (arr , skipna = False )
566
+ result = lib .infer_dtype (arr , skipna = True )
559
567
assert result == 'boolean'
560
568
561
569
arr = np .array ([True , False , True , 'foo' ], dtype = 'O' )
562
- result = lib .infer_dtype (arr , skipna = False )
570
+ result = lib .infer_dtype (arr , skipna = True )
563
571
assert result == 'mixed'
564
572
565
573
arr = np .array ([True , False , True ], dtype = bool )
566
- result = lib .infer_dtype (arr , skipna = False )
574
+ result = lib .infer_dtype (arr , skipna = True )
567
575
assert result == 'boolean'
568
576
569
577
arr = np .array ([True , np .nan , False ], dtype = 'O' )
@@ -575,38 +583,38 @@ def test_bools(self):
575
583
576
584
def test_floats (self ):
577
585
arr = np .array ([1. , 2. , 3. , np .float64 (4 ), np .float32 (5 )], dtype = 'O' )
578
- result = lib .infer_dtype (arr , skipna = False )
586
+ result = lib .infer_dtype (arr , skipna = True )
579
587
assert result == 'floating'
580
588
581
589
arr = np .array ([1 , 2 , 3 , np .float64 (4 ), np .float32 (5 ), 'foo' ],
582
590
dtype = 'O' )
583
- result = lib .infer_dtype (arr , skipna = False )
591
+ result = lib .infer_dtype (arr , skipna = True )
584
592
assert result == 'mixed-integer'
585
593
586
594
arr = np .array ([1 , 2 , 3 , 4 , 5 ], dtype = 'f4' )
587
- result = lib .infer_dtype (arr , skipna = False )
595
+ result = lib .infer_dtype (arr , skipna = True )
588
596
assert result == 'floating'
589
597
590
598
arr = np .array ([1 , 2 , 3 , 4 , 5 ], dtype = 'f8' )
591
- result = lib .infer_dtype (arr , skipna = False )
599
+ result = lib .infer_dtype (arr , skipna = True )
592
600
assert result == 'floating'
593
601
594
602
def test_decimals (self ):
595
603
# GH15690
596
604
arr = np .array ([Decimal (1 ), Decimal (2 ), Decimal (3 )])
597
- result = lib .infer_dtype (arr , skipna = False )
605
+ result = lib .infer_dtype (arr , skipna = True )
598
606
assert result == 'decimal'
599
607
600
608
arr = np .array ([1.0 , 2.0 , Decimal (3 )])
601
- result = lib .infer_dtype (arr , skipna = False )
609
+ result = lib .infer_dtype (arr , skipna = True )
602
610
assert result == 'mixed'
603
611
604
612
arr = np .array ([Decimal (1 ), Decimal ('NaN' ), Decimal (3 )])
605
- result = lib .infer_dtype (arr , skipna = False )
613
+ result = lib .infer_dtype (arr , skipna = True )
606
614
assert result == 'decimal'
607
615
608
616
arr = np .array ([Decimal (1 ), np .nan , Decimal (3 )], dtype = 'O' )
609
- result = lib .infer_dtype (arr , skipna = False )
617
+ result = lib .infer_dtype (arr , skipna = True )
610
618
assert result == 'decimal'
611
619
612
620
def test_string (self ):
@@ -648,34 +656,34 @@ def test_infer_dtype_datetime(self):
648
656
649
657
arr = np .array ([Timestamp ('2011-01-01' ),
650
658
Timestamp ('2011-01-02' )])
651
- assert lib .infer_dtype (arr , skipna = False ) == 'datetime'
659
+ assert lib .infer_dtype (arr , skipna = True ) == 'datetime'
652
660
653
661
arr = np .array ([np .datetime64 ('2011-01-01' ),
654
662
np .datetime64 ('2011-01-01' )], dtype = object )
655
- assert lib .infer_dtype (arr , skipna = False ) == 'datetime64'
663
+ assert lib .infer_dtype (arr , skipna = True ) == 'datetime64'
656
664
657
665
arr = np .array ([datetime (2011 , 1 , 1 ), datetime (2012 , 2 , 1 )])
658
- assert lib .infer_dtype (arr , skipna = False ) == 'datetime'
666
+ assert lib .infer_dtype (arr , skipna = True ) == 'datetime'
659
667
660
668
# starts with nan
661
669
for n in [pd .NaT , np .nan ]:
662
670
arr = np .array ([n , pd .Timestamp ('2011-01-02' )])
663
- assert lib .infer_dtype (arr , skipna = False ) == 'datetime'
671
+ assert lib .infer_dtype (arr , skipna = True ) == 'datetime'
664
672
665
673
arr = np .array ([n , np .datetime64 ('2011-01-02' )])
666
- assert lib .infer_dtype (arr , skipna = False ) == 'datetime64'
674
+ assert lib .infer_dtype (arr , skipna = True ) == 'datetime64'
667
675
668
676
arr = np .array ([n , datetime (2011 , 1 , 1 )])
669
- assert lib .infer_dtype (arr , skipna = False ) == 'datetime'
677
+ assert lib .infer_dtype (arr , skipna = True ) == 'datetime'
670
678
671
679
arr = np .array ([n , pd .Timestamp ('2011-01-02' ), n ])
672
- assert lib .infer_dtype (arr , skipna = False ) == 'datetime'
680
+ assert lib .infer_dtype (arr , skipna = True ) == 'datetime'
673
681
674
682
arr = np .array ([n , np .datetime64 ('2011-01-02' ), n ])
675
- assert lib .infer_dtype (arr , skipna = False ) == 'datetime64'
683
+ assert lib .infer_dtype (arr , skipna = True ) == 'datetime64'
676
684
677
685
arr = np .array ([n , datetime (2011 , 1 , 1 ), n ])
678
- assert lib .infer_dtype (arr , skipna = False ) == 'datetime'
686
+ assert lib .infer_dtype (arr , skipna = True ) == 'datetime'
679
687
680
688
# different type of nat
681
689
arr = np .array ([np .timedelta64 ('nat' ),
@@ -689,58 +697,58 @@ def test_infer_dtype_datetime(self):
689
697
# mixed datetime
690
698
arr = np .array ([datetime (2011 , 1 , 1 ),
691
699
pd .Timestamp ('2011-01-02' )])
692
- assert lib .infer_dtype (arr , skipna = False ) == 'datetime'
700
+ assert lib .infer_dtype (arr , skipna = True ) == 'datetime'
693
701
694
702
# should be datetime?
695
703
arr = np .array ([np .datetime64 ('2011-01-01' ),
696
704
pd .Timestamp ('2011-01-02' )])
697
- assert lib .infer_dtype (arr , skipna = False ) == 'mixed'
705
+ assert lib .infer_dtype (arr , skipna = True ) == 'mixed'
698
706
699
707
arr = np .array ([pd .Timestamp ('2011-01-02' ),
700
708
np .datetime64 ('2011-01-01' )])
701
- assert lib .infer_dtype (arr , skipna = False ) == 'mixed'
709
+ assert lib .infer_dtype (arr , skipna = True ) == 'mixed'
702
710
703
711
arr = np .array ([np .nan , pd .Timestamp ('2011-01-02' ), 1 ])
704
- assert lib .infer_dtype (arr , skipna = False ) == 'mixed-integer'
712
+ assert lib .infer_dtype (arr , skipna = True ) == 'mixed-integer'
705
713
706
714
arr = np .array ([np .nan , pd .Timestamp ('2011-01-02' ), 1.1 ])
707
- assert lib .infer_dtype (arr , skipna = False ) == 'mixed'
715
+ assert lib .infer_dtype (arr , skipna = True ) == 'mixed'
708
716
709
717
arr = np .array ([np .nan , '2011-01-01' , pd .Timestamp ('2011-01-02' )])
710
- assert lib .infer_dtype (arr , skipna = False ) == 'mixed'
718
+ assert lib .infer_dtype (arr , skipna = True ) == 'mixed'
711
719
712
720
def test_infer_dtype_timedelta (self ):
713
721
714
722
arr = np .array ([pd .Timedelta ('1 days' ),
715
723
pd .Timedelta ('2 days' )])
716
- assert lib .infer_dtype (arr , skipna = False ) == 'timedelta'
724
+ assert lib .infer_dtype (arr , skipna = True ) == 'timedelta'
717
725
718
726
arr = np .array ([np .timedelta64 (1 , 'D' ),
719
727
np .timedelta64 (2 , 'D' )], dtype = object )
720
- assert lib .infer_dtype (arr , skipna = False ) == 'timedelta'
728
+ assert lib .infer_dtype (arr , skipna = True ) == 'timedelta'
721
729
722
730
arr = np .array ([timedelta (1 ), timedelta (2 )])
723
- assert lib .infer_dtype (arr , skipna = False ) == 'timedelta'
731
+ assert lib .infer_dtype (arr , skipna = True ) == 'timedelta'
724
732
725
733
# starts with nan
726
734
for n in [pd .NaT , np .nan ]:
727
735
arr = np .array ([n , Timedelta ('1 days' )])
728
- assert lib .infer_dtype (arr , skipna = False ) == 'timedelta'
736
+ assert lib .infer_dtype (arr , skipna = True ) == 'timedelta'
729
737
730
738
arr = np .array ([n , np .timedelta64 (1 , 'D' )])
731
- assert lib .infer_dtype (arr , skipna = False ) == 'timedelta'
739
+ assert lib .infer_dtype (arr , skipna = True ) == 'timedelta'
732
740
733
741
arr = np .array ([n , timedelta (1 )])
734
- assert lib .infer_dtype (arr , skipna = False ) == 'timedelta'
742
+ assert lib .infer_dtype (arr , skipna = True ) == 'timedelta'
735
743
736
744
arr = np .array ([n , pd .Timedelta ('1 days' ), n ])
737
- assert lib .infer_dtype (arr , skipna = False ) == 'timedelta'
745
+ assert lib .infer_dtype (arr , skipna = True ) == 'timedelta'
738
746
739
747
arr = np .array ([n , np .timedelta64 (1 , 'D' ), n ])
740
- assert lib .infer_dtype (arr , skipna = False ) == 'timedelta'
748
+ assert lib .infer_dtype (arr , skipna = True ) == 'timedelta'
741
749
742
750
arr = np .array ([n , timedelta (1 ), n ])
743
- assert lib .infer_dtype (arr , skipna = False ) == 'timedelta'
751
+ assert lib .infer_dtype (arr , skipna = True ) == 'timedelta'
744
752
745
753
# different type of nat
746
754
arr = np .array ([np .datetime64 ('nat' ), np .timedelta64 (1 , 'D' )],
@@ -755,19 +763,19 @@ def test_infer_dtype_period(self):
755
763
# GH 13664
756
764
arr = np .array ([pd .Period ('2011-01' , freq = 'D' ),
757
765
pd .Period ('2011-02' , freq = 'D' )])
758
- assert lib .infer_dtype (arr , skipna = False ) == 'period'
766
+ assert lib .infer_dtype (arr , skipna = True ) == 'period'
759
767
760
768
arr = np .array ([pd .Period ('2011-01' , freq = 'D' ),
761
769
pd .Period ('2011-02' , freq = 'M' )])
762
- assert lib .infer_dtype (arr , skipna = False ) == 'period'
770
+ assert lib .infer_dtype (arr , skipna = True ) == 'period'
763
771
764
772
# starts with nan
765
773
for n in [pd .NaT , np .nan ]:
766
774
arr = np .array ([n , pd .Period ('2011-01' , freq = 'D' )])
767
- assert lib .infer_dtype (arr , skipna = False ) == 'period'
775
+ assert lib .infer_dtype (arr , skipna = True ) == 'period'
768
776
769
777
arr = np .array ([n , pd .Period ('2011-01' , freq = 'D' ), n ])
770
- assert lib .infer_dtype (arr , skipna = False ) == 'period'
778
+ assert lib .infer_dtype (arr , skipna = True ) == 'period'
771
779
772
780
# different type of nat
773
781
arr = np .array ([np .datetime64 ('nat' ), pd .Period ('2011-01' , freq = 'M' )],
@@ -846,7 +854,7 @@ def test_infer_datetimelike_array_nan_nat_like(self, first, second,
846
854
847
855
def test_infer_dtype_all_nan_nat_like (self ):
848
856
arr = np .array ([np .nan , np .nan ])
849
- assert lib .infer_dtype (arr , skipna = False ) == 'floating'
857
+ assert lib .infer_dtype (arr , skipna = True ) == 'floating'
850
858
851
859
# nan and None mix are result in mixed
852
860
arr = np .array ([np .nan , np .nan , None ])
@@ -1043,17 +1051,17 @@ def test_categorical(self):
1043
1051
# GH 8974
1044
1052
from pandas import Categorical , Series
1045
1053
arr = Categorical (list ('abc' ))
1046
- result = lib .infer_dtype (arr , skipna = False )
1054
+ result = lib .infer_dtype (arr , skipna = True )
1047
1055
assert result == 'categorical'
1048
1056
1049
- result = lib .infer_dtype (Series (arr ), skipna = False )
1057
+ result = lib .infer_dtype (Series (arr ), skipna = True )
1050
1058
assert result == 'categorical'
1051
1059
1052
1060
arr = Categorical (list ('abc' ), categories = ['cegfab' ], ordered = True )
1053
- result = lib .infer_dtype (arr , skipna = False )
1061
+ result = lib .infer_dtype (arr , skipna = True )
1054
1062
assert result == 'categorical'
1055
1063
1056
- result = lib .infer_dtype (Series (arr ), skipna = False )
1064
+ result = lib .infer_dtype (Series (arr ), skipna = True )
1057
1065
assert result == 'categorical'
1058
1066
1059
1067
0 commit comments