Tools for call tree conversions

Utilities to convert metrics to inclusive.

The select_metrics function may help in selecting only the metrics that can be transformed safely. To have a list of metrics to select, see the metrics module.

calltree_conversions.select_metrics(df, selected_metrics)

Selects selected_metrics out of a DataFrame.

This function solves some problems:

  • Finding the metric level in df.columns;

  • Selecting, out of selected_metrics only the ones that are also in the Data Frame;

  • Dealing with both the cases when df.columns is a pandas.MultiIndex or a pandas.Index.

Parameters
  • df (DataFrame) – A dataframe containing the metrics to be selected as columns. The dataframe columns are a MultiIndex

  • selected_metrics (iterable) – Contains the names of the metrics that need need to be selected

Returns

res – a DataFrame contaning only the selected metrics.

Return type

DataFrame

calltree_conversions.convert_df_to_inclusive(df_convertible, call_tree)

Converts a DataFrame from exclusive to inclusive. A level named Cnode ID, Full Callpath or Short Callpath must be in the index.

Parameters
  • df_convertible (pandas.DataFrame) – A DataFrame containing only metrics that can be converted safely from exclusive to inclusive.

  • call_tree (CubeTreeNode) – A recursive representation of the call tree.

Returns

res – A DataFrame

Return type

DataFrame

calltree_conversions.convert_series_to_inclusive(series, call_tree)

Converts a series having Cnode IDs as index from exclusive to inclusive. Takes as input a CubeTreeNode object (hopefully the root).

Notice: The results may be nonsensical unless the metric acted upon is “INCLUSIVE convertible”

Parameters
  • series (Series) – A series representing exclusive measurements

  • call_tree (CubeTreeNode) – A recursive representation of the call tree.

Returns

res – A series having the same structure as the input, but with data summed over following the hierarchy given by the call_tree object.

Return type

Series