You are on page 1of 7

23/08/2021 AP19110010030_Assignment-2 - Jupyter Notebook

Kilaru Sravan

AP19110010030

CSE-A

Creating a Dataset using Dictionaries


In [21]:

import pandas as pd
mobiles = {'Brand': ['Apple','MI','Samsung','Realme','Vivo','Oppo','One plus','Nokia','Micr
'Price in IND': [100000,20000,50000,35000,19000,17000,65000,15000,10000],
'Price in US': [90000,10000,40000,32000,18000,11000,45000,12000,15000]
}
df = pd.DataFrame(mobiles, columns = ['Brand', 'Price in IND','Price in US'])
print (df)
Brand Price in IND Price in US

0 Apple 100000 90000

1 MI 20000 10000

2 Samsung 50000 40000

3 Realme 35000 32000

4 Vivo 19000 18000

5 Oppo 17000 11000

6 One plus 65000 45000

7 Nokia 15000 12000

8 Micromax 10000 15000

Mean of Dataset
In [22]:

df.mean()
Out[22]:

Price in IND 36777.777778

Price in US 30333.333333

dtype: float64

Median of Dataset

localhost:8888/notebooks/AP19110010030_Assignment-2.ipynb 1/7
23/08/2021 AP19110010030_Assignment-2 - Jupyter Notebook

In [23]:

df.median()
Out[23]:

Price in IND 20000.0

Price in US 18000.0

dtype: float64

Mode of Dataset
In [24]:

df.mode()
#As there is no mode in dataset columns are printed in ascending order
Out[24]:

Brand Price in IND Price in US

0 Apple 10000 10000

1 MI 15000 11000

2 Micromax 17000 12000

3 Nokia 19000 15000

4 One plus 20000 18000

5 Oppo 35000 32000

6 Realme 50000 40000

7 Samsung 65000 45000

8 Vivo 100000 90000

Variance of Dataset
In [25]:

df.var()
Out[25]:

Price in IND 8.939444e+08

Price in US 6.727500e+08

dtype: float64

Standard Deviation of Dataset

localhost:8888/notebooks/AP19110010030_Assignment-2.ipynb 2/7
23/08/2021 AP19110010030_Assignment-2 - Jupyter Notebook

In [26]:

df.std()
Out[26]:

Price in IND 29898.903733

Price in US 25937.424699

dtype: float64

Covarience of Dataset
In [27]:

df.cov()
Out[27]:

Price in IND Price in US

Price in IND 8.939444e+08 7.579583e+08

Price in US 7.579583e+08 6.727500e+08

Correlation of Dataset
In [28]:

df.corr()
Out[28]:

Price in IND Price in US

Price in IND 1.000000 0.977379

Price in US 0.977379 1.000000

Importing Dataset from internet sources

localhost:8888/notebooks/AP19110010030_Assignment-2.ipynb 3/7
23/08/2021 AP19110010030_Assignment-2 - Jupyter Notebook

In [31]:

# reading data which is in csv


df1=pd.read_csv('food.csv')
df1 #prints the data in csv file
Out[31]:

name ingredients diet prep_time cook_time flavor_profile course state r

Maida flour,
Balu West
0 yogurt, oil, vegetarian 45 25 sweet dessert
shahi Bengal
sugar

Gram flour,
1 Boondi vegetarian 80 30 sweet dessert Rajasthan
ghee, sugar

Carrots,
Gajar milk, sugar,
2 ka ghee, vegetarian 15 60 sweet dessert Punjab
halwa cashews,
raisins

Flour, ghee,
kewra, milk,
3 Ghevar vegetarian 15 30 sweet dessert Rajasthan
clarified
butter, su...

Milk
powder,
Gulab plain flour, West
4 vegetarian 15 40 sweet dessert
jamun baking Bengal
powder,
ghee,...

... ... ... ... ... ... ... ... ...

Glutinous
rice, black
250 Til Pitha vegetarian 5 30 sweet dessert Assam
sesame
seeds, gur

Coconut
milk, egg
251 Bebinca yolks, vegetarian 20 60 sweet dessert Goa
clarified
butter, all...

Cottage
cheese, dry
Jammu &
252 Shufta dates, dried vegetarian -1 -1 sweet dessert
Kashmir
rose petals,
...

Milk
powder, dry
Mawa fruits, Madhya
253 vegetarian 20 45 sweet dessert C
Bati arrowroot Pradesh
powder,
all...

Brown rice,
fennel
seeds,
254 Pinaca vegetarian -1 -1 sweet dessert Goa
grated
coconut,
blac...

255 rows × 9 columns

localhost:8888/notebooks/AP19110010030_Assignment-2.ipynb 4/7
23/08/2021 AP19110010030_Assignment-2 - Jupyter Notebook

Mean of Food Dataset


In [34]:

df1.mean()
Out[34]:

prep_time 31.105882

cook_time 34.529412

dtype: float64

Median of Food Dataset


In [35]:

df1.median()
Out[35]:

prep_time 10.0

cook_time 30.0

dtype: float64

Mode of Food Dataset

localhost:8888/notebooks/AP19110010030_Assignment-2.ipynb 5/7
23/08/2021 AP19110010030_Assignment-2 - Jupyter Notebook

In [36]:

df1.mode()
Out[36]:

name ingredients diet prep_time cook_time flavor_profile course state re

Arbi ke
patte,
sesame main
0 Adhirasam vegetarian 10.0 30.0 spicy Gujarat
seeds, gur, course
bengal
gram ...

Chhena,
1 Aloo gobi NaN NaN NaN NaN NaN NaN
sugar, ghee

Aloo Gram flour,


2 NaN NaN NaN NaN NaN NaN
matar ghee, sugar

3 Aloo methi NaN NaN NaN NaN NaN NaN NaN

Aloo
4 shimla NaN NaN NaN NaN NaN NaN NaN
mirch

... ... ... ... ... ... ... ... ...

250 Vada NaN NaN NaN NaN NaN NaN NaN

Veg
251 NaN NaN NaN NaN NaN NaN NaN
Kolhapuri

Vegetable
252 NaN NaN NaN NaN NaN NaN NaN
jalfrezi

253 Vindaloo NaN NaN NaN NaN NaN NaN NaN

254 Zunka NaN NaN NaN NaN NaN NaN NaN

255 rows × 9 columns

Variance of Food Dataset


In [37]:

df1.var()
Out[37]:

prep_time 5264.142288

cook_time 2329.572950

dtype: float64

Standard Deviation of Food Dataset

localhost:8888/notebooks/AP19110010030_Assignment-2.ipynb 6/7
23/08/2021 AP19110010030_Assignment-2 - Jupyter Notebook

In [38]:

df1.std()
Out[38]:

prep_time 72.554409

cook_time 48.265650

dtype: float64

Covariance of Food Dataset


In [39]:

df1.cov()
Out[39]:

prep_time cook_time

prep_time 5264.142288 504.668133

cook_time 504.668133 2329.572950

Correlation of Food Dataset


In [40]:

df1.corr()
Out[40]:

prep_time cook_time

prep_time 1.000000 0.144113

cook_time 0.144113 1.000000

localhost:8888/notebooks/AP19110010030_Assignment-2.ipynb 7/7

You might also like