You are on page 1of 1

In 

[4]: import pandas as pd

import numpy as np

from pandas import Series ,DataFrame

import matplotlib.pyplot as plt

In [2]: df = pd.read_excel('Group-8.xlsx')

df.head()

Out[2]: Patient Id Age Gender Air Pollution Alcohol use Dust Allergy OccuPational Hazards Genetic Risk chronic Lung Disease Balanced Diet ... Fatigue Weight Loss Shortness of Breath Wheezing Swallowing Difficulty Clubbing of Finger Nails Frequent Cold Dry Cough Snoring Level

0 P1 33 1 2 4 5 4 3 2 2 ... 3 4 2 2 3 1 2 3 4 Low

1 P10 17 1 3 1 5 3 4 2 2 ... 1 3 7 8 6 2 1 7 2 Medium

2 P100 35 1 4 5 6 5 5 4 6 ... 8 7 9 2 1 4 6 7 2 High

3 P1000 37 1 7 7 7 7 6 7 7 ... 4 2 3 1 4 5 6 7 5 High

4 P101 46 1 6 8 7 7 7 6 7 ... 3 2 4 1 4 2 4 2 3 High

5 rows × 25 columns

In [ ]: #the number of cancer patients below 30

In [3]: ages = df["Age"] < 30

age = df[df['Age'].between(0, 30)]

ageBelow = len(age)

print("Age Below 30 is" +" "+ str(ageBelow))

Age Below 30 is 301

In [ ]: #the number of male and female patients

In [4]: malesex = df[df['Gender'].between(0, 1)]

nummalesex = len(malesex)

print("number of males is" +" "+ str(nummalesex))

number of males is 598

In [5]: femalesex = df[df['Gender'].between(2, 3)]

numfemalesex = len(femalesex)

print("number of females is" +" "+ str(numfemalesex))

number of females is 402

In [ ]: #the number of patients in genetic risk

In [6]: geneticrisks = df[df['Genetic Risk'].between(5, 10)]

numofgeneticrisks = len(geneticrisks)

print("number of people geneticrisks above 5 is" +" "+ str(numofgeneticrisks))

number of people geneticrisks above 5 is 535

In [ ]: #charts

In [7]: highrisk = df['Level'].value_counts()['High']

print("number of high risks is")

print(highrisk)

lowrisk = df['Level'].value_counts()['Low']

print("number of low risks is")


print(lowrisk)

mediumrisk = df['Level'].value_counts()['Medium']

print("number of medium risks is")

print(mediumrisk)

number of high risks is

365

number of low risks is

303

number of medium risks is

332

In [ ]: #bar chart

In [5]: import matplotlib.pyplot as plt

x=["high risk","medium risk","low risk"]

y=[365,332,303]

plt.xlabel("genetic level",loc="center")

plt.ylabel("number of patients",loc="center")

plt.bar(x,y,color="c")

plt.draw()

In [ ]: #pie chart

In [8]: plt.pie(y,labels=x,autopct='%1.1f%%',pctdistance=0.6,labeldistance=1.1)

plt.show()

In [ ]: #average patients of male and female

In [30]: series=pd.Series([598,402])

print("Pandas Series: \n",series)

series_mean=series.mean()

print("mean of the panda series:\n",series_mean)

Pandas Series:

0 598

1 402

dtype: int64

mean of the panda series:

500.0

You might also like