1

With a dataFrame like this:

Time                    Status      ResponseTime     PID
2016-07-13 17:33:49     OK          1623             42
2016-07-13 17:33:50     KO          1593             35
2016-07-13 17:33:50     OK          1604             19
2016-07-13 17:33:51     KO          1605             28
2016-07-13 17:33:51     OK          1617             42
2016-07-13 17:33:52     OK          1654             35
2016-07-13 17:33:52     OK          2044             19
2016-07-13 17:33:53     KO          1630             42

How can I draw a kind of a histogram which would present number of KOs and OKs for each minute?

vestland
  • 43,687
  • 29
  • 146
  • 249
Snorlax
  • 717
  • 1
  • 7
  • 16

1 Answers1

3
text = """Time                    Status      ResponseTime     PID
2016-07-13 17:33:49     OK          1623             42
2016-07-13 17:33:50     KO          1593             35
2016-07-13 17:33:50     OK          1604             19
2016-07-13 17:33:51     KO          1605             28
2016-07-13 17:33:51     OK          1617             42
2016-07-13 17:33:52     OK          1654             35
2016-07-13 17:33:52     OK          2044             19
2016-07-13 17:33:53     KO          1630             42
2016-07-13 17:34:49     OK          1623             42
2016-07-13 17:34:50     KO          1593             35
2016-07-13 17:34:50     OK          1604             19
2016-07-13 17:34:51     KO          1605             28
2016-07-13 17:34:51     OK          1617             42
2016-07-13 17:34:52     OK          1654             35
2016-07-13 17:34:52     OK          2044             19
2016-07-13 17:34:53     KO          1630             42
"""

df = pd.read_csv(StringIO(text), sep='\s{2,}', engine='python', index_col=0, parse_dates=[0])

df1 = df.groupby(pd.TimeGrouper('Min')).Status.value_counts().unstack()
df1

enter image description here

df1.plot.bar()

enter image description here

If you want to limit to 'KO':

df1.KO.plot.bar()

enter image description here

piRSquared
  • 265,629
  • 48
  • 427
  • 571