chart_me.charting_assembly_strategy
Specify AssembleChartsStrategy Protocol; Default Implementation of Chart Assembly
The AssembleChartsStrategy Protocal requires one method - assemble_charts that return a list of High Level Altair Charts or Compound Chart. The AssembleChartStrategy expects two MetaData Objects InferedDataTypes that specificy metadata about columns in the dataframe.
Typical usage example:
assembler = AssembleChartsStrategyDefault(df, cols, infer_dtypes) charts = assembler.assemble_charts()
Submodules
Exceptions
Implementation of error if there's no valid columns to chart |
Classes
Defines Normalized Datatypes |
|
Core Object Returned for Assembler - column level specifications |
|
Defines the protocol type for AssembleChartsStrategy |
|
Default implementation of AssembleChartsStrategy |
Functions
|
Delegated Function to Manage Bivariate Use Cases |
|
Delegated Function to Manage Univariate Use Cases |
Package Contents
- class chart_me.charting_assembly_strategy.ChartMeDataType(*args, **kwds)[source]
Bases:
enum.EnumDefines Normalized Datatypes
- FLOATS = 'F'
- INTEGER = 'I'
- TEMPORAL = ('T',)
- NOMINAL = ('N',)
- NOT_SUPPORTED_TYPE = 'NA'
- class chart_me.charting_assembly_strategy.InferedDataTypes[source]
Core Object Returned for Assembler - column level specifications
- preaggregated: bool
- chart_me_data_types: Dict[str, ChartMeDataType]
- chart_me_data_types_meta: Dict[str, ChartMeDataTypeMetaType]
- exception chart_me.charting_assembly_strategy.InsufficientValidColumnsError[source]
Bases:
ExceptionImplementation of error if there’s no valid columns to chart
- chart_me.charting_assembly_strategy.assemble_bivariate_charts(df: pandas.DataFrame, cols: List[str], infered_data_types: chart_me.datatype_infer_strategy.InferedDataTypes, **kwargs) List[altair.Chart | altair.HConcatChart][source]
Delegated Function to Manage Bivariate Use Cases
- Parameters:
df – dataframe
cols – a list of two columns
infered_data_types – An instance of InferedDataTypes object
- Returns:
List of altair charts or compounds charts
- Raises:
ValueError if called with len of cols != 2 –
- chart_me.charting_assembly_strategy.assemble_univariate_charts(df: pandas.DataFrame, cols: List[str], infered_data_types: chart_me.datatype_infer_strategy.InferedDataTypes, **kwargs) List[altair.Chart | altair.HConcatChart][source]
Delegated Function to Manage Univariate Use Cases
- Parameters:
df – dataframe
cols – a single column name in a list
infered_data_types – An instance of InferedDataTypes object
- Returns:
List of altair charts or compounds charts
- Raises:
ValueError if called with more then one column –
- class chart_me.charting_assembly_strategy.AssembleChartsStrategy[source]
Bases:
ProtocolDefines the protocol type for AssembleChartsStrategy
Protocal requires 1 method — assemble_charts
- assemble_charts() List[altair.Chart | altair.HConcatChart][source]
Defines Protocal Type for AssembleChartsStrategy
- Parameters:
df (pd.DataFrame)
cols (List[str]) – at least 1 and no more then 2 at this time
infered_data_types (InferedDataTypes) – metadata required to guide viz logic
- Returns:
return a list of Altair visuals
- Return type:
List[Union[alt.Chart, alt.HConcatChart]]
- class chart_me.charting_assembly_strategy.AssembleChartsStrategyDefault(df: pandas.DataFrame, cols: List[str], infered_data_types: chart_me.datatype_infer_strategy.InferedDataTypes, **kwargs)[source]
Default implementation of AssembleChartsStrategy
Default implementation strategy provided by chart_me. The core logic is provided by seperate modules depending on number of columns provided - so far 2 are build univariate & bivariate. More then 2 columns will throw an error
- assemble_charts() List[altair.Chart | altair.HConcatChart][source]
assembles charts based on columns count
- Returns:
A list of Altair Chart/Compound charts to display
- Raises:
InsufficientValidColumnsError – Will occur if no columns available after removing unsupported types.
NotImplementedError – Only support 1 or 2 columns at this time