@@ -907,6 +907,13 @@ def test_nan_first_take_datetime(self):
907
907
exp = Index ([idx [- 1 ], idx [0 ], idx [1 ]])
908
908
tm .assert_index_equal (res , exp )
909
909
910
+ def test_dropna (self ):
911
+ idx = Index ([np .nan , 'a' , np .nan , np .nan , 'b' , 'c' , np .nan ],
912
+ name = 'idx' )
913
+ expected = Index (['a' , 'b' , 'c' ], name = 'idx' )
914
+ result = idx .dropna ()
915
+ tm .assert_index_equal (result , expected )
916
+
910
917
911
918
class TestFloat64Index (tm .TestCase ):
912
919
_multiprocess_can_split_ = True
@@ -1051,6 +1058,12 @@ def test_astype_from_object(self):
1051
1058
tm .assert_equal (result .dtype , expected .dtype )
1052
1059
tm .assert_index_equal (result , expected )
1053
1060
1061
+ def test_dropna (self ):
1062
+ idx = Float64Index ([np .nan , 1.0 , np .nan , np .nan , 2.0 , 3.0 , np .nan ])
1063
+ expected = Float64Index ([1.0 , 2.0 , 3.0 ])
1064
+ result = idx .dropna ()
1065
+ tm .assert_index_equal (result , expected )
1066
+
1054
1067
1055
1068
class TestInt64Index (tm .TestCase ):
1056
1069
_multiprocess_can_split_ = True
@@ -1476,6 +1489,12 @@ def test_slice_keep_name(self):
1476
1489
idx = Int64Index ([1 , 2 ], name = 'asdf' )
1477
1490
self .assertEqual (idx .name , idx [1 :].name )
1478
1491
1492
+ def test_dropna_does_nothing (self ):
1493
+ idx = Int64Index ([1 , 2 , 3 ], name = 'idx' )
1494
+ expected = Int64Index ([1 , 2 , 3 ], name = 'idx' )
1495
+ result = idx .dropna ()
1496
+ tm .assert_index_equal (result , expected )
1497
+
1479
1498
1480
1499
class TestMultiIndex (tm .TestCase ):
1481
1500
_multiprocess_can_split_ = True
@@ -2948,6 +2967,12 @@ def test_level_setting_resets_attributes(self):
2948
2967
# if this fails, probably didn't reset the cache correctly.
2949
2968
assert not ind .is_monotonic
2950
2969
2970
+ def test_dropna_does_nothing (self ):
2971
+ idx = MultiIndex .from_tuples ([('bar' , 'two' )])
2972
+ expected = idx
2973
+ result = idx .dropna ()
2974
+ tm .assert_index_equal (result , expected )
2975
+
2951
2976
2952
2977
def test_get_combined_index ():
2953
2978
from pandas .core .index import _get_combined_index
0 commit comments