1
Running the code:
def novacoluna(df):
coluna_adicionada = {}
coluna_adicionada['retorno_diario']= df['quota_value']/df['quota_deslocada']
return pd.Series(coluna_adicionada, index=['retorno_diario'])
agrupamento_por_fundo = df.groupby([df['fund_name'], df['date']]).apply(novacoluna)
To add a new column to the grouped dataframe, when I run group_por_background.head() the data appears this way:
How do I add only account results in column, without 10397 before and dtype after?
pq Have you created a function to add column? Try to create the column directly
– Lucas