Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

How to find correlation among multiple attributes in group by dataframe object?

$
0
0

@shounakrockz47 wrote:

I have a data frame with following attributes :

CP - Counting point of vehicles

A-Junction - Starting node of a road

B-Junction - Ending node of a road

Road - Road name

Date - Date

Time - Time

Vehicle Count - Number of vehicles

I have found that the combination of CP , A-Junction and B-Junction is unique.

So , I can group the dataframe using these three (CP,A-Junction,B-Junction)

CP   A-Junction  B-Junction Road    Date       Time  Vehicle Count
X1        A1          B1     R1    2000-06-09    7       10
X1        A1          B1     R1    2000-06-09    8       15
X1        A1          B1     R1    2000-06-09    9       18
X1        A1          B1     R1    2000-06-09    10      12
X1        A1          B1     R1    2000-06-09    11      25


X2        A1          B1     R1    2000-06-09    7       15
X2        A1          B1     R1    2000-06-09    8       20
X2        A1          B1     R1    2000-06-09    8       20

How can I find the correlation between these combinations?

I want to build a correlation matrix

                (X1-A1-B1)      (X2-A1-B1) ....  
   (X1-A1-B1)      1             <some value>
   (X2-A1-B1)     <some value>     1

Is there any way I can do this ?

Edit1

dictAMV={}
for name,groups in group_by_lat_lon:
    grp=group_by_lat_lon.get_group(name)
    if(name in dictAMV.keys()):
        print("This key ",name," already exists")
    else:
        amvListTemp=[]
        for index,row in grp.iterrows():
            amvListTemp.append(row['Vehicle_count'])
        dictAMV[name]=amvListTemp

I am able to form a dictionary which contains all vehicle counts .
Now , how can I build the matrix .

Can you please help ?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles