sbu.dataframe_postprocess¶
A module for creating new dataframes from the SBU-containing dataframe.
Index¶
Construct a new Pandas DataFrame with SBU usage per project. |
|
Calculate the SBU accumulated over all months in the |
|
Calculate the % accumulated SBU usage per project. |
|
|
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 byget_sbu()
.pandas.DataFrame.columns
andpandas.DataFrame.index
should be instances ofpandas.MultiIndex
andpandas.Index
, respectively.- Returns
A new Pandas DataFrame holding the SBU usage per project (i.e. df [project]).
- Return type
- 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 byget_sbu_per_project()
.pandas.DataFrame.columns
andpandas.DataFrame.index
should be instances ofpandas.MultiIndex
andpandas.Index
, respectively.- Returns
A new Pandas DataFrame with SBU usage accumulated over all columns in the
"Month"
super-column.- Return type
- 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 byget_agregated_sbu()
.pandas.DataFrame.columns
andpandas.DataFrame.index
should be instances ofpandas.MultiIndex
andpandas.Index
, respectively.- Returns
A new Pandas DataFrame with % SBU usage accumulated over all columns in the
"Month"
super-column.- Return type