Research breakthrough possible @S-Logix pro@slogix.in

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to find correlation between two variables using kendal method in python?

Description

To find correlation using kendal method using python.

Process

  Import kendal method from scipy.stats.

  Load the sample data set.

  Pass the arguments x and y to the kendal().

Sample Code

#import pandas library

import pandas as pd

#import kendal method from scipy.stats

from scipy.stats import kendalltau

#load sample data

data={‘salary’:[1000,200,300,400

,50,400,300,2000,100,50],

‘age’:[25,26,25,23,30,29,23,23,25,25],

‘rating’:[4,3.24,2.5,2.25,2,2.25,2.5,2.75,

3.2,4.2], ‘bonus’:[2500,1200,900,3000,

1800,1400,850,250,750,1000]}

#create and store the data into a data frame

df=pd.DataFrame(data)

print(“Actual Data frame\n”,df)

#pass the arguments to kendal()

p=kendalltau(df[‘salary’],df[‘age’])

q=kendalltau(df[‘rating’],df[‘bonus’])

#print the results

print(p)

print(q)

Screenshots
find correlation between two variables using kendal method in python
import pandas library