Merge pull request #38 from stevedodson/master

Adding Series.isin
This commit is contained in:
stevedodson 2019-11-15 02:59:01 +01:00 committed by GitHub
commit 850e3f0d73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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