0% found this document useful (0 votes)
17 views

Python Pandas - Hands On 1

This document imports pandas and numpy libraries. It creates two dataframes (df_A and df_B) containing student height and weight data. df_A contains lists of heights and weights, while df_B contains randomly generated height and weight data. Various properties of the dataframes like shape, columns, and mean are printed.

Uploaded by

Abhilash Jose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Python Pandas - Hands On 1

This document imports pandas and numpy libraries. It creates two dataframes (df_A and df_B) containing student height and weight data. df_A contains lists of heights and weights, while df_B contains randomly generated height and weight data. Various properties of the dataframes like shape, columns, and mean are printed.

Uploaded by

Abhilash Jose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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