Adding Series.isin

This commit is contained in:
Stephen Dodson 2019-11-14 20:25:34 +00:00
parent 4719afa57f
commit fb2774e7c7
2 changed files with 16 additions and 5 deletions

View File

@ -20,7 +20,7 @@ import warnings
import pandas as pd
from eland import NDFrame
from eland.filter import NotFilter, Equal, Greater, Less, GreaterEqual, LessEqual, ScriptFilter
from eland.filter import NotFilter, Equal, Greater, Less, GreaterEqual, LessEqual, ScriptFilter, IsIn
class Series(NDFrame):
@ -216,6 +216,12 @@ class Series(NDFrame):
else:
raise NotImplementedError(other, type(other))
def isin(self, other):
if isinstance(other, list):
return IsIn(field=self.name, value=other)
else:
raise NotImplementedError(other, type(other))
@property
def ndim(self):
"""

View File

@ -43,11 +43,16 @@ class TestDataFrameQuery(TestData):
assert_pandas_eland_frame_equal(pd_q4, ed_q4)
def test_query(self):
def test_simple_query(self):
ed_flights = self.ed_flights()
pd_flights = self.pd_flights()
#print(ed_flights.query('FlightDelayMin > 60').info_es())
assert pd_flights.query('FlightDelayMin > 60').shape == \
ed_flights.query('FlightDelayMin > 60').shape
print(pd_flights.query('FlightDelayMin > 60').shape)
print(ed_flights.query('FlightDelayMin > 60').shape)
def test_isin_query(self):
ed_flights = self.ed_flights()
pd_flights = self.pd_flights()
assert pd_flights[pd_flights.OriginAirportID.isin(['LHR','SYD'])].shape == \
ed_flights[ed_flights.OriginAirportID.isin(['LHR','SYD'])].shape