I am using pandas to process a dataset (see samples below), where t
and tu
are timestamp (epoch in seconds and microsecond respectively). and br
and bw
are cumulative values at the sample time. I'd like to perform two actions:
- split groups based
A
andB
(there maybe many) - for each group, I'd like to compute the delta of
br
andbw
, e.g.br[n] - br[n-1]
I am having difficulty to figure this out, any help is appreciated.
# data as dictionary
data = {0: {'group': 'A', 't': 1532973555, 'tu': 319007, 'br': 28, 'bw': 32},
1: {'group': 'B', 't': 1532973555, 'tu': 319638, 'br': 100, 'bw': 200},
2: {'group': 'A', 't': 1532973999, 'tu': 320594, 'br': 75, 'bw': 86},
3: {'group': 'B', 't': 1532973999, 'tu': 320652, 'br': 300, 'bw': 500}}
# read into dataframe
df = pd.DataFrame.from_dict(data, orient="index")