-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChapter 6.py
32 lines (22 loc) · 912 Bytes
/
Chapter 6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
#Question 5
df = pd.read_excel('Ch06/Ch06/Excel/Armspans.xlsx',engine='openpyxl')
print(df.head()) # See the top 5 rows of the dataframe
plt.scatter(df['Armspan_cm'], df['Height_cm'])
plt.title('Height vs. Armspan')
plt.xlabel('Armspan (cm)')
plt.ylabel('Height (cm)')
plt.show()
#Question 42
df = pd.read_excel('Ch06/Ch06/Excel/Vehicle_weights.xlsx',engine='openpyxl')
print(np.corrcoef(df['Static Weight'], df['Weight-in-Motion'])[0, 1])
df['Static Weight kg'] = df['Static Weight'] * 0.4545
print(np.corrcoef(df['Static Weight kg'], df['Weight-in-Motion'])[0, 1])
print(df.head()) # See the top 5 rows of the dataframe
plt.scatter(df['Static Weight'], df['Weight-in-Motion'])
plt.title('Weight-in-Motion vs. Static Weight')
plt.xlabel('Static Weight (1000s of lbs)')
plt.ylabel('Weight-in-Motion (1000s of lbs)')
plt.show()