I have this data frame:
Node Band 5-May 12-May 19-May 26-May 2-June
Server1 10000 800 1000 12000 12500 500
Server2 30000 600 3000 12000 12500 500
Server3 17000 1500 12000 12500 500 1000
I need to calculate usage by dividing column values right of “Band” column by the values in “Band” column in pandas.
Resulting data frame should look like this:
df1
Node Band 5-May 12-May 19-May 26-May 2-June
Server1 10000 0.08 0.10 1.2 1.25 0.05
Server2 30000 0.02 0.1 0.4 0.42 0.02
etc
then I have to count the them if they fall withing certain percentage per node. if any date, usage per node between 70% and 80%, the count for that node is one, however many times the usage is between those thresholds. In this example for Node “Server1”, number of times it breached 100% is 2.
For example:
All summary:
Node 70%-80% 80%-90% 90%-100% 100%+
Server1 0 0 0 2
Server2 0 0 0 0
I can do this by explicitly dividing columns by Band column but the number of columns is not known, it could be many columns.
df['5-May_%']=df['5-May']/df['Band']