@@ -1257,6 +1257,14 @@ def get_reindex_type(target):
1257
1257
self .assertEqual (reindexed .levels [0 ].dtype .type , np .int64 )
1258
1258
self .assertEqual (reindexed .levels [1 ].dtype .type , np .float64 )
1259
1259
1260
+ def test_dropna (self ):
1261
+ idx = Index ([np .nan , 'a' , np .nan , np .nan , 'b' , 'c' , np .nan ],
1262
+ name = 'idx' )
1263
+ expected = Index (['a' , 'b' , 'c' ], name = 'idx' )
1264
+ result = idx .dropna ()
1265
+ tm .assert_index_equal (result , expected )
1266
+
1267
+
1260
1268
def test_groupby (self ):
1261
1269
idx = Index (range (5 ))
1262
1270
groups = idx .groupby (np .array ([1 ,1 ,2 ,2 ,2 ]))
@@ -1513,6 +1521,12 @@ def test_astype_from_object(self):
1513
1521
tm .assert_equal (result .dtype , expected .dtype )
1514
1522
tm .assert_index_equal (result , expected )
1515
1523
1524
+ def test_dropna (self ):
1525
+ idx = Float64Index ([np .nan , 1.0 , np .nan , np .nan , 2.0 , 3.0 , np .nan ])
1526
+ expected = Float64Index ([1.0 , 2.0 , 3.0 ])
1527
+ result = idx .dropna ()
1528
+ tm .assert_index_equal (result , expected )
1529
+
1516
1530
1517
1531
class TestInt64Index (Numeric , tm .TestCase ):
1518
1532
_holder = Int64Index
@@ -2085,6 +2099,14 @@ def test_time_loc(self): # GH8667
2085
2099
2086
2100
tm .assert_array_equal (ts .index .get_loc (key ), i )
2087
2101
tm .assert_series_equal (ts [key ], ts .iloc [i ])
2102
+ == == == =
2103
+ def test_dropna_does_nothing (self ):
2104
+ idx = Int64Index ([1 , 2 , 3 ], name = 'idx' )
2105
+ expected = Int64Index ([1 , 2 , 3 ], name = 'idx' )
2106
+ result = idx .dropna ()
2107
+ tm .assert_index_equal (result , expected )
2108
+
2109
+ >> >> >> > dropna method added to Index .
2088
2110
2089
2111
left , right = ts .copy (), ts .copy ()
2090
2112
left [key ] *= - 10
@@ -3890,6 +3912,7 @@ def test_level_setting_resets_attributes(self):
3890
3912
# if this fails, probably didn't reset the cache correctly.
3891
3913
assert not ind .is_monotonic
3892
3914
3915
+ < << << << HEAD
3893
3916
def test_isin (self ):
3894
3917
values = [('foo' , 2 ), ('bar' , 3 ), ('quux' , 4 )]
3895
3918
@@ -3988,6 +4011,13 @@ def test_groupby(self):
3988
4011
groups = self .index .groupby (self .index )
3989
4012
exp = dict ((key , [key ]) for key in self .index )
3990
4013
tm .assert_dict_equal (groups , exp )
4014
+ == == == =
4015
+ def test_dropna_does_nothing (self ):
4016
+ idx = MultiIndex .from_tuples ([('bar' , 'two' )])
4017
+ expected = idx
4018
+ result = idx .dropna ()
4019
+ tm .assert_index_equal (result , expected )
4020
+ >> >> >> > dropna method added to Index .
3991
4021
3992
4022
3993
4023
def test_get_combined_index ():
0 commit comments