Lab 3

You might also like

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

#import numpy and panads libraries

import pandas as pd
import numpy as np

#Read the le with the name "martsales.csv" using panadas (1 mark)

df = pd.read_csv(«martsales.csv»)

#view the your data

df

#Calculate the mean of 'Item_MRP' and 'Item_Outlet_Sales' (1 mark)

print('Mean of Item_MRP:', df['Item_MRP'].mean())


print('Mean of Item_Outlet_Sales:', df[‘Item_Outlet_Sales'].mean())

#Calculate the median of 'Item_MRP' and 'Item_Outlet_Sales' (1 mark)

print('Median of Item_MRP:', df['Item_MRP'].median())


print('Median of Item_Outlet_Sales:', df[‘Item_Outlet_Sales'].median())

#Calculate the mode of 'Item_MRP' and 'Item_Outlet_Sales' (1 mark)

print('Mode of Item_MRP:', df['Item_MRP'].mode())


print('Mode of Item_Outlet_Sales:', df['Item_Outlet_Sales'].mode())

#Calaculate the range of 'Item_MRP' (1 mark)

range = max(df['Item_MRP']) - min(df['Item_MRP'])


print('Range for Item_MRP:’,range)

#Calculate the stndard deviation of 'Item_MRP' and


'Item_Outlet_Sales' (1 mark)

print('Standart deviation of Item_MRP :', df['Item_MRP'].std())


print('Standart deviation of Item_Outlet_Sales :', df['Item_Outlet_Sales'].std())

#Calculate the varianace of 'Item_MRP' and 'Item_Outlet_Sales' (1 mark)

print('Variance of Item_MRP :', df['Item_MRP'].var())


print('Variance of Item_Outlet_Sales :', df[‘Item_Outlet_Sales'].var())
fi
#Calculate IQR of 'Item_MRP' and 'Item_Outlet_Sales' (1 mark)

from scipy.stats import iqr


print('IQR of Item_MRP :', iqr(df['Item_MRP']))
print('IQR of Item_Outlet_Sales :', iqr(df['Item_Outlet_Sales']))

#Calculate Skewness and Kurtosis (Pearson and Fisher) of


'Item_Outlet_Sales' (1 mark)

from scipy.stats import kurtosis


print(f"Pearson kurtosis: {kurtosis(df['Item_Outlet_Sales'], sher=False)} ")
print(f"Fisher's kurtosis: {kurtosis(df['Item_Outlet_Sales'], sher=True)} «)
from scipy.stats import skew
skew(df['Item_Outlet_Sales'])

#Calculate Z-Score of 'Item_MRP' and 'Item_Outlet_Sales' (1 mark)

from scipy.stats import zscore

# zscore(df[‘Item_MRP’])

zscore(df['Item_MRP'])

# zscore(df[‘Item_Outlet_Sales’])

zscore(df['Item_Outlet_Sales'])

s = df['Item_MRP'].std()
(((df['Item_MRP'] - df['Item_MRP'].mean()).sum())/s )
(((df['Item_Outlet_Sales'] - df['Item_Outlet_Sales'].mean()).sum())/s )
fi
fi

You might also like