My first dataframe is this :
I need to make a group by date AND make a log add on column "SEL"
So, I can do the group by date like this :
df.groupby([df.index.date])["SEL"]
But the formula is
CodePudding user response:
Create new column with GroupBy.transform
and set missing values to all column per date without last by Series.mask
:
dates = df.index.normalize()
df['new'] = (10*np.log10((10**(df["SEL"]/10)).groupby(dates).transform('sum'))
.mask(dates.duplicated(keep='last')))