bayesline.api.equity.UploadParserApi#
- class bayesline.api.equity.UploadParserApi#
Abstract base class for upload parsers.
- __init__()#
Methods
__init__()can_handle(raw_df, *[, name])Check if this parser can handle the given dataframe.
Get example dataframes for testing the parser.
Get the output schema that this parser produces.
parse(raw_df, *[, name])Parse the given dataframe.
Attributes
Get the name of the parser.
- abstract output_schema() dict[str, DataType]#
Get the output schema that this parser produces.
Returns#
- dict[str, pl.DataType]
The schema that this parser produces.
- abstract get_examples() list[DataFrame]#
Get example dataframes for testing the parser.
Returns#
- list[pl.DataFrame]
A list of example portfolios that can be used to test the parser.
- abstract can_handle(raw_df: DataFrame, *, name: str | None = None) UploadParserResult#
Check if this parser can handle the given dataframe.
Parameters#
- raw_dfpl.DataFrame
The dataframe to check if the parser can handle.
- namestr | None, default=None
The name of the dataframe (which could be the filename). Some parsers might extract information (such as a date) from the name.
Returns#
- UploadParserResult
Result indicating whether the parser can handle the dataframe.
- abstract parse(raw_df: DataFrame, *, name: str | None = None) tuple[DataFrame, UploadParserResult]#
Parse the given dataframe.
Parameters#
- raw_dfpl.DataFrame
The dataframe to parse.
- namestr | None, default=None
The name of the dataframe (which could be the filename). Some parsers might extract information (such as a date) from the name.
Returns#
- tuple[pl.DataFrame, UploadParserResult]
A tuple of the parsed pl.DataFrame and a UploadParserResult. If the parser was unsuccessful the parsed dataframe will instead be a (possibly empty) error dataframe.