Example #1
0
 def test_per_different_table_by_same_as_clause(
     self, holidays, bookings, people, flights
 ):
     """clause: Bookings, per: People, by: Bookings"""
     flights_only_1000_highest_cost_per_income = NPerVariableClause(
         flights, 1000, people["Income"], by=bookings["Cost"], session=holidays
     )
     assert flights_only_1000_highest_cost_per_income.count() == 9409
Example #2
0
 def test_per_by_same_table(self, holidays, bookings, flights):
     """clause: Bookings, per: Bookings, by: Bookings"""
     flights_only_12_per_dest_by_profit = NPerVariableClause(
         flights,
         12,
         bookings["Destination"],
         by=bookings["Profit"],
         session=holidays,
     )
     assert flights_only_12_per_dest_by_profit.count() == 228
Example #3
0
 def test_per_different_table_by_different_table(
     self, holidays, households, people, flights
 ):
     """clause: Bookings, per: People, by: households"""
     flights_only_75_per_region_by_oldest_person = NPerVariableClause(
         flights,
         75,
         households["Region"],
         by=people["DOB"],
         ascending=True,
         session=holidays,
     )
     assert flights_only_75_per_region_by_oldest_person.count() == 1125
Example #4
0
 def _as_nper_clause(self, clause, n, by, ascending, label):
     return NPerVariableClause(
         clause=clause,
         n=n,
         per=self,
         by=by,
         ascending=ascending,
         label=label,
         session=self.session,
     )
Example #5
0
 def test_per_different_table_by_same_as_per(self, holidays, people, flights):
     """clause: Bookings, per: People, by: People"""
     flights_only_2_per_surname_by_top_income = NPerVariableClause(
         flights, 2, people["Surname"], by=people["Income"], session=holidays
     )
     assert flights_only_2_per_surname_by_top_income.count() == 89233
Example #6
0
 def test_per_different_table_any(self, holidays, people, flights):
     """clause: Bookings, per: People, by: None"""
     flights_only_any_500_per_occupation = NPerVariableClause(
         flights, 500, people["Occupation"], session=holidays
     )
     assert flights_only_any_500_per_occupation.count() == 5500
Example #7
0
 def test_per_same_table_by_different(self, holidays, bookings, people, flights):
     """clause: Bookings, per: Bookings, by: People"""
     flights_only_12_per_dest_by_profit = NPerVariableClause(
         flights, 12, bookings["Destination"], by=people["DOB"], session=holidays
     )
     assert flights_only_12_per_dest_by_profit.count() == 228
Example #8
0
 def test_per_same_table_any(self, holidays, bookings, flights):
     """clause: Bookings, per: Bookings, by: None"""
     flight_only_any_250_per_dest = NPerVariableClause(
         flights, 250, bookings["Destination"], session=holidays
     )
     assert flight_only_any_250_per_dest.count() == 3217