0

Need some help here:

df.groupby('cnpj').apply(v1).reset_index()
    
         cnpj               0
0    Category 1      0.322412

I need V1 = 0.322412. Actually I´m trying this:I need each variable the result of the respective function, in a result Dataframe.

    v1 = df.groupby('cnpj').apply(v1).reset_index()
    v2 = df.groupby('cnpj').apply(v2).reset_index()
    v3 = df.groupby('cnpj').apply(v3).reset_index()
    v4 = df.groupby('cnpj').apply(v4).reset_index()
    v5 = df.groupby('cnpj').apply(v5).reset_index()
    v6 = df.groupby('cnpj').apply(v6).reset_index()
    v7 = df.groupby('cnpj').apply(v7).reset_index()
    v8 = df.groupby('cnpj').apply(v8).reset_index()
    v9 = df.groupby('cnpj').apply(v9).reset_index()

   frame = { 'CDI5a': v1, 'ATIVO5a': v2,'ATIVOanual': v3,'VOLAT': v4,'ALFA': v5,'BETA': 
   v6,'SHARPE': v7,'TRACKING_ERR': v8,'R²': v9 }

   result = pd.DataFrame(frame)
   result
Fcoatis
  • 85
  • 1
  • 2
  • 11
  • [How to make good reproducible pandas examples](/q/20109391/843953) Please provide a [mre] that we can run to reproduce your problem. Also include expected vs. actual output. – Pranav Hosangadi May 10 '22 at 18:25
  • Hello @PranavHosangadi. My Dataframe is too large to reproduce here. My question is how can I get row 1, column2 of each of the above dataframes and assign to variables? TIA – Fcoatis May 10 '22 at 18:46
  • Surely you can condense your dataframe down into a representative dataframe that would allow us to test our suggestions in context of your data? – Pranav Hosangadi May 10 '22 at 18:47

0 Answers0