Pandasbasics - Ipynb - Colaboratory (Day3)
Pandasbasics - Ipynb - Colaboratory (Day3)
ipynb - Colaboratory
import pandas as pd
heartdata=pd.read_csv("/content/Dataset.csv")
print(heartdata)
type(heartdata)
heartdata.shape
(1190, 12)
heartdata.info()
heartdata.head()
heartdata.columns
heartdata
2 37 1 2 130 283 0 1 98
heartdata['target']
heartdata.describe()
603
149
heartdata.iloc[149]['cholesterol']
# find the number of people suffereing from heartdisease and not suffering from heart dise
heartdata['target'].value_counts()
1 909
0 281
Name: sex, dtype: int64
#display the records of males suffering from heartdisease in ascending order of age
x=heartdata[(heartdata['sex']==1) & (heartdata['target']==1)]
print(x)
print(x.sort_values('age'))
https://colab.research.google.com/drive/1A699lGpJALnxi0hbrcd2eRffGRZCdwBk#scrollTo=nK8gakKahAEz&printMode=true 2/3
5/12/2021 Pandasbasics(day3).ipynb - Colaboratory
70
233
#No. of persons having cholesterol >250 and not suffering from heardisease
heartdata[(heartdata['cholesterol']>250) & (heartdata['target']==0)].shape[0]
193
40
0s completed at 7:12 PM
https://colab.research.google.com/drive/1A699lGpJALnxi0hbrcd2eRffGRZCdwBk#scrollTo=nK8gakKahAEz&printMode=true 3/3