SimTabCarriers¶
-
class passengersim.summaries.carriers.SimTabCarriers(data: dict[str, pd.DataFrame] =
None, *, config: Config | None =None, cnx: Database | None =None, sim: Simulation | None =None, n_total_samples: int =0, items: Collection[str] =(), callback_data: CallbackData | None =None)[source]¶ Bases:
GenericSimulationTablesContainer for summary tables and figures extracted from a Simulation.
This class is a subclass of GenericSimulationTables, which is defined in the generic module. It lists the items that are available in the SimulationTables class, and provides type hints and (optionally, but ideally) documentation for the data that is stored in each item.
Methods
__init__([data, config, cnx, sim, ...])aggregate(summaries)Aggregate multiple summary tables.
extract(sim[, items])Extract summary data from a Simulation.
fig_carrier_head_to_head_revenue(x_carrier, ...)Figure comparing carrier revenues head-to-head.
fig_carrier_load_factors([load_measure, ...])fig_carrier_local_share([load_measure, ...])fig_carrier_mileage(*[, raw_df, also_df])Figure showing mileage by carrier.
fig_carrier_rasm(*[, raw_df, also_df, title])fig_carrier_revenue_distribution(*[, ...])Figure showing the distribution of carrier revenues.
fig_carrier_revenues(*[, raw_df, also_df, title])fig_carrier_total_bookings(*[, raw_df, ...])fig_carrier_yields(*[, raw_df, also_df, title])Generate a figure showing carrier yields.
fig_leg_bid_price_detail_rake(*, leg_id[, ...])fig_leg_bid_price_history(carrier, *, measure)fig_leg_booking_detail_rake(*, leg_id[, ...])Return information about the file store.
from_file(filename[, read_latest, lazy])Load the object from a file.
from_pickle(filename[, read_latest])Load the object from a pickle file.
metadata([key])Return a metadata value.
remove_data(keys)Remove data from the summary tables.
run_queries([cnx, items, scenario, burn_samples])Query summary data from a Database.
save(filename, *[, timestamp, make_dirs, ...])Save the object to a set of files.
Return a list of all concrete subclasses.
to_file(filename[, add_timestamp_ext, ...])Write simulation tables to a file.
to_html(filename, *[, cfg, make_dirs, ...])Write simulation tables report summary to html.
to_pickle(filename[, add_timestamp_ext, ...])Save to a pickle file.
to_xlsx(filename)Write simulation tables to excel.
Attributes
Carrier-level summary data from each sample.
Carrier-level summary data from each sample, new version with counters in CoreCarrier.
Carrier-level summary data.
Summary of forecast history, based on UA's EDGAR approach
Database connection for the Simulation run.
Simulation object for the Simulation run.
Total number of sample departures simulated to create these summaries.
Summaries that were aggregated to create this summary.
- carriers : pd.DataFrame¶
Carrier-level summary data.
- carrier_history : pd.DataFrame | None¶
Carrier-level summary data from each sample.
- carrier_history2 : pd.DataFrame | None¶
Carrier-level summary data from each sample, new version with counters in CoreCarrier.
- forecast_accuracy : pd.DataFrame | None¶
Summary of forecast history, based on UA’s EDGAR approach
-
fig_carrier_load_factors(load_measure: 'sys_lf' | 'avg_leg_lf' =
'sys_lf', *, raw_df: bool =False, also_df: bool =False, title: str | None ='_default_')[source]¶
-
fig_carrier_revenues(*, raw_df: bool =
False, also_df: bool =False, title: str | None ='Carrier Revenues')[source]¶
-
fig_carrier_yields(*, raw_df: bool =
False, also_df: bool =False, title: str | None ='Carrier Yields')[source]¶ Generate a figure showing carrier yields.
Notes
Yield is defined as revenue per revenue passenger-mile. It differs from RASM (revenue per available seat mile) in that it only considers revenue and miles from paying passengers, If a seat is flown empty, it does not generate revenue or contribute to RPM, so it does not affect yield, but it does reduce RASM since it contributes to ASM. Yield is often considered a better measure of the price level that a carrier is achieving, while RASM is a better measure of overall revenue efficiency. Both measures are useful for understanding carrier performance, and they can sometimes move in different directions, so it’s helpful to look at both.
-
fig_carrier_rasm(*, raw_df: bool =
False, also_df: bool =False, title: str | None ='Carrier Revenue per Available Seat Mile (RASM)')[source]¶
-
fig_carrier_total_bookings(*, raw_df: bool =
False, also_df: bool =False, title: str | None ='Carrier Total Bookings')[source]¶
-
fig_carrier_mileage(*, raw_df: bool =
False, also_df: bool =False) alt.Chart | pd.DataFrame | tuple[alt.Chart, pd.DataFrame][source]¶ Figure showing mileage by carrier.
ASM is available seat miles, and RPM is revenue passenger miles. Both measures are reported as the average across all non-burned samples.
- Parameters:
- raw_df : bool, default False¶
Return the raw data for this figure as a pandas DataFrame, instead of generating the figure itself.
- report : xmle.Reporter, optional
Also append this figure to the given report.
- trace : pd.ExcelWriter, optional
Also write the data from this figure to the given Excel file.
-
fig_carrier_revenue_distribution(*, raw_df=
False, also_df=False)[source]¶ Figure showing the distribution of carrier revenues.
- Parameters:
- raw_df : bool, default False¶
Return the raw data for this figure as a pandas DataFrame, instead of generating the figure itself. This is not implemented yet and will raise an error if set.
- also_df : bool, default False¶
Return the raw data for this figure as a pandas DataFrame, in addition to the figure itself. This is not implemented yet, and will be silently ignored if set.
-
fig_carrier_head_to_head_revenue(x_carrier: str, y_carrier: str, *, raw_df=
False, mean_adjusted: bool =True)[source]¶ Figure comparing carrier revenues head-to-head.
- Parameters:
- x_carrier : str¶
The carrier to plot on the x- and y-axis, respectively.
- y_carrier : str¶
The carrier to plot on the x- and y-axis, respectively.
- raw_df : bool, default False¶
Return the raw data for this figure as a pandas DataFrame, instead of generating the figure itself.
- mean_adjusted : bool, default True¶
If True, adjust revenues by dividing by the mean revenue for each carrier, so that the plot shows percentage of mean revenue. If False, use raw revenues, which is generally only useful for analyzing symmetric networks, such as 3MKT.
- Returns:
alt.Chart | pd.DataFrame – The Altair chart object, or the raw data as a pandas DataFrame
- classmethod aggregate(summaries: Collection[GenericSimulationTables]) Self¶
Aggregate multiple summary tables.
- property callback_data¶
- property config¶
-
classmethod extract(sim: Simulation, items: Collection[str] =
()) Self¶ Extract summary data from a Simulation.
-
fig_leg_bid_price_detail_rake(*, leg_id: int, raw_df: bool =
False, color: str ='#6a3d9a', mean_color: str | None ='#ff7f00')¶
-
fig_leg_bid_price_history(carrier: str, *, measure: 'mean' | 'q10' | 'q25' | 'q50' | 'q75' | 'q90' | 'median', haul_category_labels: tuple[str, ...] | None =
('a. Short: ', 'b. Medium: ', 'c. Long: ', 'd. Longest: '), opacity: float =0.25, max_rows: int =5000) alt.Chart¶
- file_info()¶
Return information about the file store.
-
classmethod from_file(filename: str | Path, read_latest: bool =
True, lazy: bool =True)¶ Load the object from a file.
-
classmethod from_pickle(filename: str | Path, read_latest: bool =
True)¶ Load the object from a pickle file.
- property leg_bid_price_detail¶
- property leg_booking_detail¶
- remove_data(keys: Collection[str] | str) Self¶
Remove data from the summary tables.
This can be used to reduce the size of the summary tables when saving to a file, or to remove sensitive data before sharing the summary tables.
- Parameters:
- keys : Collection[str] or str¶
The key(s) of the data to remove.
- Returns:
Self – The summary tables object, with the specified data removed.
-
run_queries(cnx: Database =
None, items: Collection[str] | None =None, *, scenario: str =None, burn_samples: int | None =None) Self¶ Query summary data from a Database.
The requested items will be queried from the database and stored in this summary object. If the item is not available, an exception will be raised.
- Parameters:
- cnx : Database, optional¶
Database connection to use for querying.
- items : Collection[str], optional¶
The items to query. If None, or if only “*” is given, then all available items will be queried.
- scenario : str, optional¶
The scenario to use for querying.
- burn_samples : int, optional¶
The number of burn samples to use for querying. If explicitly None, the burn_samples value from the configuration will be used if available, otherwise the default value of 100 will be used.
-
save(filename: str | Path, *, timestamp: float | struct_time | datetime | None =
None, make_dirs: True | False | 'git' =True, cfg: Config | None =None, extra_html: tuple =()) dict[str, Path]¶ Save the object to a set of files.
This method will write both an HTML report on this simulation tables object and a “.pxsim” file allowing the content to be restored.
- Parameters:
- filename : Path-like¶
The file stem to use for writing files.
- timestamp : float or time.struct_time or datetime, optional¶
The timestamp to use for the filenames. If not provided, the current time will be used.
- make_dirs : bool or "git", default True¶
If True, create the parent directory for the files if it does not already exist. If the directory is created, it will be created with a .gitignore file to prevent accidental inclusion of output in Git repositories, unless the value is “git”, in which case no .gitignore file is created and the results will be eligible for inclusion in Git.
- cfg : Config, optional¶
The configuration to use for the HTML report. If None, the configuration from the simulation object will be used if available.
- extra_html : tuple, optional¶
Additional data to include in the HTML report. This argument is passed to to_html, see that function for more details.
- Returns:
dict – A dictionary of filenames written, including the timestamp added.
- classmethod subclasses() list[type[GenericSimulationTables]]¶
Return a list of all concrete subclasses.
User defined subclasses (those not in the passengersim package) are at the front of the list, so they come first in MRO and thus can override native subclasses.
-
to_file(filename: str | Path, add_timestamp_ext: bool =
True, *, preserve_config: bool =True, make_dirs: True | False | 'git' =True) Path¶ Write simulation tables to a file.
- Parameters:
- filename : Path-like¶
The file to write.
- add_timestamp_ext : bool, default True¶
Add a timestamp extension to the filename.
- preserve_config : bool, default True¶
Preserve the config attribute in the saved object. This includes the entire network, and can potentially be a lot of data.
- make_dirs : bool or "git", default True¶
If True, create the parent directory for the file if it does not already exist. If the directory is created, it will be created with a .gitignore file to prevent accidental inclusion of output in Git repositories, unless the value is “git”, in which case no .gitignore file is created and the results will be eligible for inclusion in Git.
- Returns:
Path-like – The resolved filename for the saved outputs.
-
to_html(filename: str | Path, *, cfg: Config | None =
None, make_dirs: bool =True, extra: tuple =(), add_timestamp: bool =True) Path¶ Write simulation tables report summary to html.
- Parameters:
- filename : Path-like, optional¶
The html file to write.
- cfg : Config, optional¶
The configuration to use for the report. If None, the configuration from the simulation object will be used.
- make_dirs : bool, default True¶
If True, create any necessary directories.
- extra : tuple, optional¶
Additional data to include in the report. Each item in the tuple should either a section or subsection title, or a tuple of (title, func), or just a function. If a function is provided, it should take the summary as its only argument and return a figure (altair.Chart or xmle.Elem) or table (pandas.DataFrame). The function will be called with the summary as its only argument. To use a function that requires other arguments, use functools.partial provide the other arguments.
- add_timestamp : bool, default True¶
If True, append a timestamp to the filename. This ensures that each report is unique and does not overwrite previous reports. If False, the filename will be used as-is. Set this to False if you want to overwrite previous reports with the same filename, or if you are already setting the timestamp yourself.
- Returns:
Path-like – The resolved filename for the saved outputs.
-
to_pickle(filename: str | Path, add_timestamp_ext: bool =
True, *, preserve_meta_summaries: bool =False, preserve_config: bool =True, make_dirs: True | False | 'git' =True) Path¶ Save to a pickle file.
This method uses lz4 compression if the lz4.frame module is available.
- Parameters:
- filename : str or Path-like¶
The filename to save the object to. An extension map be added or modified, to optionally add a time stamp and/or compression flag.
- add_timestamp_ext : bool, default True¶
Add a timestamp extension to the filename.
- preserve_meta_summaries : bool, default False¶
Preserve the meta_summaries attribute in the saved object.
- preserve_config : bool, default False¶
Preserve the config attribute in the saved object. This includes the entire network, and can potentially be a lot of data.
- make_dirs : bool or "git", default True¶
If True, create the parent directory for the pickle file if it does not already exist. If the directory is created, it will be created with a .gitignore file to prevent accidental inclusion of pickled output in Git repositories, unless the value is “git”, in which case no .gitignore file is created and the results will be eligible for inclusion in Git.
- Returns:
Path-like – The resolved filename for the saved outputs.
- to_xlsx(filename: str | Path) None¶
Write simulation tables to excel.
- Parameters:
- filename : Path-like¶
The excel file to write.
- cnx¶
Database connection for the Simulation run.
- sim¶
Simulation object for the Simulation run.
- n_total_samples¶
Total number of sample departures simulated to create these summaries.
This excludes any burn samples.
- meta_summaries¶
Summaries that were aggregated to create this summary.