sbu.dataframe_postprocess

A module for creating new dataframes from the SBU-containing dataframe.

Index

get_sbu_per_project(df)

Construct a new Pandas DataFrame with SBU usage per project.

get_agregated_sbu(df)

Calculate the SBU accumulated over all months in the "Month" super-column.

get_percentage_sbu(df)

Calculate the % accumulated SBU usage per project.

_get_active_name(df, index)

Return a tuple with the names of all active users.

API

sbu.dataframe_postprocess.get_sbu_per_project(df)[source]

Construct a new Pandas DataFrame with SBU usage per project.

Parameters

df (pandas.DataFrame) – A Pandas DataFrame with SBU usage per username, constructed by get_sbu(). pandas.DataFrame.columns and pandas.DataFrame.index should be instances of pandas.MultiIndex and pandas.Index, respectively.

Returns

A new Pandas DataFrame holding the SBU usage per project (i.e. df [project]).

Return type

pandas.DataFrame

sbu.dataframe_postprocess.get_agregated_sbu(df)[source]

Calculate the SBU accumulated over all months in the "Month" super-column.

Examples

Considering the following DataFrame as input:

>>> print(df['Month'])
                2019-01  2019-02  2019-03
username
Donald Duck      1000.0   1500.0    750.0
Scrooge McDuck   1000.0    500.0    250.0
Mickey Mouse     1000.0   5000.0   4000.0

Which will be accumulated along each column in the following manner:

>>> df_new = get_agregated_sbu(df)
>>> print(df_new['Month'])
                2019-01  2019-02  2019-03
username
Donald Duck      1000.0   2500.0   3250.0
Scrooge McDuck   1000.0   1500.0   1750.0
Mickey Mouse     1000.0   6000.0  10000.0
Parameters

df (pandas.DataFrame) – A Pandas DataFrame with SBU usage per project, constructed by get_sbu_per_project(). pandas.DataFrame.columns and pandas.DataFrame.index should be instances of pandas.MultiIndex and pandas.Index, respectively.

Returns

A new Pandas DataFrame with SBU usage accumulated over all columns in the "Month" super-column.

Return type

pandas.DataFrame

sbu.dataframe_postprocess.get_percentage_sbu(df)[source]

Calculate the % accumulated SBU usage per project.

The column storing the requested amount of SBUs can be defined in the global variable _GLOBVAR["SBU_REQUESTED"] (default value: ("info", "SBU requested")).

Examples

Considering the following DataFrame with accumulated SBUs as input:

>>> print(df)
                        info   Month
               SBU requested 2019-01 2019-02  2019-03
username
Donald Duck           3250.0  1000.0  2500.0   3250.0
Scrooge McDuck        5000.0  1000.0  1500.0   1750.0
Mickey Mouse          5000.0  1000.0  6000.0  10000.0

Which will result in the following SBU usage:

>>> df_new = get_percentage_sbu(df)
>>> print(df_new['Month'])
                2019-01  2019-02  2019-03
username
Donald Duck        0.31     0.77     1.00
Scrooge McDuck     0.20     0.30     0.35
Mickey Mouse       0.20     1.20     2.00
Parameters

df (pandas.DataFrame) – A Pandas DataFrame with the accumulated SBU usage per project, constructed by get_agregated_sbu(). pandas.DataFrame.columns and pandas.DataFrame.index should be instances of pandas.MultiIndex and pandas.Index, respectively.

Returns

A new Pandas DataFrame with % SBU usage accumulated over all columns in the "Month" super-column.

Return type

pandas.DataFrame

sbu.dataframe_postprocess._get_active_name(df, index)[source]

Return a tuple with the names of all active users.

Return type

tuple