def test_cube_to_df_people_dimensions_bookings_table( self, people, bookings, cube_003_people_dimensions_bookings_table): cube = bookings.cube([people[var] for var in ("Source", "Occupation")]) df = cube.to_df(unclassified=True, totals=True) assert_cube_dataframes_match( df, cube_003_people_dimensions_bookings_table)
def test_cube_to_df_people_various_dimensions( self, people, cube_001_people_various_dimensions): cube = people.cube( [people[var] for var in ("Income", "Occupation", "Source")]) df = cube.to_df(unclassified=True, totals=True) assert_cube_dataframes_match(df, cube_001_people_various_dimensions)
def test_cube_to_df_bookings_single_dimension_default_count_measure_table( self, holidays, bookings, cube_007_bookings_single_dimension_default_count_measure, ): cube = bookings.cube([bookings["Destination"]]) df = cube.to_df(unclassified=True, totals=True) assert_cube_dataframes_match( df, cube_007_bookings_single_dimension_default_count_measure, False)
def test_cube_to_df_mixed_households_people_dimensions_households_table( self, households, people, cube_005_mixed_households_people_dimensions_households_table, ): cube = households.cube([people[var] for var in ("Income", "Gender")] + [households["Region"]]) df = cube.to_df(unclassified=True, totals=True) assert_cube_dataframes_match( df, cube_005_mixed_households_people_dimensions_households_table)
def test_cube_to_df_bookings_before_2020_cost_less_than_500( self, bookings, cube_002_bookings_before_2020_cost_less_than_500): before_2020_cost_less_than_500 = (bookings["Cost"] < 500) & ( bookings["boDate"] <= datetime(2019, 12, 31)) cube = before_2020_cost_less_than_500.cube([ bookings[var] for var in ("Destination", "Product", "Response Code") ]) df = cube.to_df(unclassified=True, totals=True) assert_cube_dataframes_match( df, cube_002_bookings_before_2020_cost_less_than_500)
def test_cube_to_df_bookings_dimensions_households_selection_people_table( self, households, people, bookings, cube_004_bookings_dimensions_households_selection_people_table, ): north_west_or_f_car = (households["Region"] == ("02", "13")) | ( households["HHCarmak"] == ("FER", "FIA", "FOR")) cube = north_west_or_f_car.cube( [bookings[var] for var in ("Product", "Continent")], table=people) df = cube.to_df(unclassified=True, totals=True) assert_cube_dataframes_match( df, cube_004_bookings_dimensions_households_selection_people_table)
def test_cube_to_df_mixed_hhds_jnys_ppl_dimensions_people_selection_journeys_table( self, households, people, bookings, journeys, cube_006_mixed_hhds_jnys_ppl_dimensions_people_selection_journeys_table, ): cube = journeys.cube( [households["Region"], journeys["Pool"], people["Gender"]], selection=((people["Surname"].contains(["int", "str", "bool"], match_case=False)) | (bookings["Continent"] == ("AM", "AU"))), ) df = cube.to_df(unclassified=True, totals=True) assert_cube_dataframes_match( df, cube_006_mixed_hhds_jnys_ppl_dimensions_people_selection_journeys_table )