Hello Everyone! My name is Andrew Fung, in this video, we will be using the Python Pandas library to calculate the correlation coefficients between 2 variables to find out which are the top 5 attributes related to the increase in COVID-19 cases.
#python #pandas #correlation #covid-19dataset #dataAnalysis
Installation and Setup!
Installing Jupyter Notebook: https://jupyter.readthedocs.io/en/lat...
Installing the Python Pandas library: https://pandas.pydata.org/pandas-docs...
Check out my Github!
https://github.com/Andrew-FungKinHo
How I make my YouTube videos:
⌨️ Keyboard - Nuphy Air75 Mechanical Keyboard - https://amzn.to/3Xu4PD3
🎙 Microphone - MAONO A04 Professional Podcaster USB Microphone - https://amzn.to/3k8ocD5
🖱 Mouse - Microsoft Bluetooth Ergonomic Mouse - https://amzn.to/3CHhdHJ
🔌 Accessories - Laptop Docking Station for MacBook Pro - https://amzn.to/3CHi5Mv
Full code:
import pandas as pd
df = pd.read_csv('covid_train.csv')
adding Quantile_rank column to the DataFrame
df['Quantile_rank'] = pd.qcut(df['pop_density'], 5,
labels = False)
exception_headers = ['country_name','country_code','pop_total','pop_density','new_cases_percentages', 'Quantile_rank']
for i in range(0,5,1):
quantile_group = df[df['Quantile_rank'] == i].groupby('Quantile_rank')
new_df = quantile_group.get_group(float(i))
correlation_dict = {}
for column in new_df:
if column in exception_headers:
continue
else:
correlation_dict[str(column)] = abs(new_df['new_cases_percentages'].corr(df[column]))
correlation_dict = {k: v for k, v in sorted(correlation_dict.items(), key=lambda item: item[1],reverse=True)}
print('For Quantile ' + str(i) + ": ")
for x in list(correlation_dict)[0:5]:
print ("Attr: {}, correlation: {} ".format(x,correlation_dict[x]))
print('------------------------------------------------')
Feel free to drop a like and comment if you enjoy and video and let me know if you want me to do other types of programming videos ;) !!!
On this page of the site you can watch the video online Finding the correlation coefficients between two variables --- Data Analysis with Python and Pandas with a duration of hours minute second in good quality, which was uploaded by the user Andrew Fung 02 January 2021, share the link with friends and acquaintances, this video has already been watched 1,271 times on youtube and it was liked by 14 viewers. Enjoy your viewing!