Python Pandas - Hands On 1

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import pandas as pd

import numpy as np
s1 = 176.2
s2 = 158.4
s3 = 167.6
s4 = 156.2
s5 = 161.4
heights_A_list = [s1,s2,s3,s4,s5]
heights_A = pd.Series(heights_A_list)
print(heights_A.shape)

s1 = 85.1
s2 = 90.2
s3 = 76.8
s4 = 80.4
s5 = 78.9
weights_A_list = [s1,s2,s3,s4,s5]
weights_A = pd.Series(weights_A_list)
print(weights_A.dtype)

data = {"Student_height": heights_A,


"Student_weight": weights_A}

df_A = pd.concat(data, axis = 1)


print(df_A.shape)
print(df_A)

np.random.seed(100)
heights_B_numpy = np.random.normal(loc=170.0, scale=25.0, size=5)
weights_B_numpy = np.random.normal(loc=75.0, scale=12.0, size=5)

#print("heights_B",heights_B)
#print("weights_B",weights_B)

heights_B = pd.Series(heights_B_numpy)

weights_B = pd.Series(weights_B_numpy)
print(heights_B.mean())

data_B = {"Student_height": heights_B,


"Student_weight": weights_B}

df_B = pd.concat(data_B, axis = 1)


print(list(df_B.columns.values))

You might also like