@@ -905,6 +905,13 @@ def test_nan_first_take_datetime(self):
905
905
exp = Index ([idx [- 1 ], idx [0 ], idx [1 ]])
906
906
tm .assert_index_equal (res , exp )
907
907
908
+ def test_dropna (self ):
909
+ idx = Index ([np .nan , 'a' , np .nan , np .nan , 'b' , 'c' , np .nan ],
910
+ name = 'idx' )
911
+ expected = Index (['a' , 'b' , 'c' ], name = 'idx' )
912
+ result = idx .dropna ()
913
+ tm .assert_index_equal (result , expected )
914
+
908
915
909
916
class TestFloat64Index (tm .TestCase ):
910
917
_multiprocess_can_split_ = True
@@ -1049,6 +1056,12 @@ def test_astype_from_object(self):
1049
1056
tm .assert_equal (result .dtype , expected .dtype )
1050
1057
tm .assert_index_equal (result , expected )
1051
1058
1059
+ def test_dropna (self ):
1060
+ idx = Float64Index ([np .nan , 1.0 , np .nan , np .nan , 2.0 , 3.0 , np .nan ])
1061
+ expected = Float64Index ([1.0 , 2.0 , 3.0 ])
1062
+ result = idx .dropna ()
1063
+ tm .assert_index_equal (result , expected )
1064
+
1052
1065
1053
1066
class TestInt64Index (tm .TestCase ):
1054
1067
_multiprocess_can_split_ = True
@@ -1474,6 +1487,12 @@ def test_slice_keep_name(self):
1474
1487
idx = Int64Index ([1 , 2 ], name = 'asdf' )
1475
1488
self .assertEqual (idx .name , idx [1 :].name )
1476
1489
1490
+ def test_dropna_does_nothing (self ):
1491
+ idx = Int64Index ([1 , 2 , 3 ], name = 'idx' )
1492
+ expected = Int64Index ([1 , 2 , 3 ], name = 'idx' )
1493
+ result = idx .dropna ()
1494
+ tm .assert_index_equal (result , expected )
1495
+
1477
1496
1478
1497
class TestMultiIndex (tm .TestCase ):
1479
1498
_multiprocess_can_split_ = True
@@ -2824,6 +2843,12 @@ def test_level_setting_resets_attributes(self):
2824
2843
# if this fails, probably didn't reset the cache correctly.
2825
2844
assert not ind .is_monotonic
2826
2845
2846
+ def test_dropna_does_nothing (self ):
2847
+ idx = MultiIndex .from_tuples ([('bar' , 'two' )])
2848
+ expected = idx
2849
+ result = idx .dropna ()
2850
+ tm .assert_index_equal (result , expected )
2851
+
2827
2852
2828
2853
def test_get_combined_index ():
2829
2854
from pandas .core .index import _get_combined_index
0 commit comments