File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ pandas 0.8.2
93
93
- Basic indexing now works on MultiIndex with > 1000000 elements, regression
94
94
from earlier version of pandas (#1757)
95
95
- Handle non-float64 dtypes in fast DataFrame.corr/cov code paths (#1761)
96
+ - Fix DatetimeIndex.isin to function properly (#1763)
96
97
97
98
pandas 0.8.1
98
99
============
Original file line number Diff line number Diff line change @@ -499,6 +499,28 @@ def __contains__(self, key):
499
499
except (KeyError , TypeError ):
500
500
return False
501
501
502
+ def isin (self , values ):
503
+ """
504
+ Compute boolean array of whether each index value is found in the
505
+ passed set of values
506
+
507
+ Parameters
508
+ ----------
509
+ values : set or sequence of values
510
+
511
+ Returns
512
+ -------
513
+ is_contained : ndarray (boolean dtype)
514
+ """
515
+ if not isinstance (values , DatetimeIndex ):
516
+ try :
517
+ values = DatetimeIndex (values )
518
+ except ValueError :
519
+ return self .asobject .isin (values )
520
+
521
+ value_set = set (values .asi8 )
522
+ return lib .ismember (self .asi8 , value_set )
523
+
502
524
def to_datetime (self , dayfirst = False ):
503
525
return self .copy ()
504
526
Original file line number Diff line number Diff line change @@ -1304,6 +1304,17 @@ def test_append_numpy_bug_1681(self):
1304
1304
result = a .append (c )
1305
1305
self .assert_ ((result ['B' ] == dr ).all ())
1306
1306
1307
+ def test_isin (self ):
1308
+ index = tm .makeDateIndex (4 )
1309
+ result = index .isin (index )
1310
+ self .assert_ (result .all ())
1311
+
1312
+ result = index .isin (list (index ))
1313
+ self .assert_ (result .all ())
1314
+
1315
+ assert_almost_equal (index .isin ([index [2 ], 5 ]),
1316
+ [False , False , True , False ])
1317
+
1307
1318
class TestLegacySupport (unittest .TestCase ):
1308
1319
1309
1320
@classmethod
You can’t perform that action at this time.
0 commit comments