Python Forum
How to group variables & check correlation of group variables wrt single variable
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to group variables & check correlation of group variables wrt single variable
#1
Var1   Var2    Var3  
6       4.6    5
8       5.9    6 
14      8.2    8 
6       1      2.6 
7       2.6    9.3  
9       11.2   0.2 
4       5      2.9
6       3      6
2       1      3
I want check correlation of (1) Var1,Var2,Var3 & (2)I want to group Var1&Var3=Var4 and check correlation of Var1,Var2,Var3,Var4

I want correlation table as below:
     Var1  Var2  Var3
Var1
Var2
Var3

             Var1    Var2    Var3  Var4(Var1$Var3)
Var1
Var2
Var3
Var4(Var1$Var3)
Reply
#2
What have you tried? We are glad to help, but we are not going to do it for you. Please, post your code in python tags, full traceback if you get any exceptions - in error tags and ask specific questions.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
I tried as Below:
My input matrix is stored in dataframe

import pandas as pd
df = pd.DataFrame({'Var1': [6,8,14,6,7,9,4,6,2], 'Var2': [4.6,5.9,8.2,1,2.6,11.2,5,3,1],'Var3': [5,6,8,2.6,9.3,0.2,2.9,8,3]})
pd.scatter_matrix(df, alpha = 0.3, figsize = (14,8), diagonal = 'kde');
but I don't know how group Var4(i.e., Var1&Var3), and re-do above process
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SORTED.group by and count average of two columns [ sum of col 1 / sum of col 2 ] BSDevo 1 638 Oct-23-2023, 09:47 PM
Last Post: BSDevo
  How to run a linear model by group in Python? Betty775522 0 515 Oct-18-2023, 07:09 PM
Last Post: Betty775522
  Sorting data by specific variables using argparse Bearinabox 5 1,369 Jan-01-2023, 07:44 PM
Last Post: Bearinabox
  Add group number for duplicates atomxkai 2 1,094 Dec-08-2022, 06:08 AM
Last Post: atomxkai
  Different Correlation Coefficents with different Time Ranges giaco__mar 0 833 Sep-28-2022, 02:03 PM
Last Post: giaco__mar
  ValueError: Found input variables with inconsistent numbers of samples: [5, 6] bongielondy 6 25,321 Jun-28-2021, 05:23 AM
Last Post: ricslato
  Check if a Group/dataset path exists paul18fr 0 1,640 Jun-10-2021, 12:03 PM
Last Post: paul18fr
  Time Series forecating with multiple independent variables Krychol88 1 1,823 Oct-23-2020, 08:11 AM
Last Post: DPaul
  Extract the categorial variables of a DataFrame Tut 1 2,099 Sep-20-2020, 09:21 AM
Last Post: scidam
  ValueError: Found input variables with inconsistent numbers of sample robert2joe 0 4,215 Mar-25-2020, 11:10 AM
Last Post: robert2joe

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020