Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Челендж 2 | Коваріація та Кореляція
Вивчення Статистики з Використанням Python

book
Челендж 2

Завдання

Swipe to start coding

Обчисліть коваріацію та кореляцію між стовпчиками 'Daily_Customer_Count' та 'Items_Available' за допомогою бібліотеки NumPy.

Рішення

import pandas as pd
import numpy as np

df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/update/Stores.csv')

# Calculate the covariance
cov = np.cov(df['Daily_Customer_Count'], df['Items_Available'])[0,1]
# Calculate the correlation
corr = np.corrcoef(df['Daily_Customer_Count'], df['Items_Available'])[0,1]

print("The covariance is", round(cov, 2))
print("The correlation is", round(corr, 2))
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 4
import pandas as pd
import numpy as np

df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/update/Stores.csv')

# Calculate the covariance
cov = np.___(df['Daily_Customer_Count'], df['___'])[0,1]
# Calculate the correlation
corr = ___(___)[0,1]

print("The covariance is", round(cov, 2))
print("The correlation is", round(corr, 2))
toggle bottom row
some-alt