{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd \nimport numpy as np\nfname='../input/titanic/train.csv'\ndata=pd.read_csv(fname)\n","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:25.632848Z","iopub.execute_input":"2022-08-10T08:45:25.633293Z","iopub.status.idle":"2022-08-10T08:45:25.682535Z","shell.execute_reply.started":"2022-08-10T08:45:25.633204Z","shell.execute_reply":"2022-08-10T08:45:25.681540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"len(data)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:25.684669Z","iopub.execute_input":"2022-08-10T08:45:25.685850Z","iopub.status.idle":"2022-08-10T08:45:25.696254Z","shell.execute_reply.started":"2022-08-10T08:45:25.685811Z","shell.execute_reply":"2022-08-10T08:45:25.695162Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"data.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:25.697697Z","iopub.execute_input":"2022-08-10T08:45:25.698126Z","iopub.status.idle":"2022-08-10T08:45:25.730545Z","shell.execute_reply.started":"2022-08-10T08:45:25.698092Z","shell.execute_reply":"2022-08-10T08:45:25.729114Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.count()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:25.734052Z","iopub.execute_input":"2022-08-10T08:45:25.734887Z","iopub.status.idle":"2022-08-10T08:45:25.748164Z","shell.execute_reply.started":"2022-08-10T08:45:25.734836Z","shell.execute_reply":"2022-08-10T08:45:25.746970Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['Age'].min(),data['Age'].max()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:25.750690Z","iopub.execute_input":"2022-08-10T08:45:25.751638Z","iopub.status.idle":"2022-08-10T08:45:25.763329Z","shell.execute_reply.started":"2022-08-10T08:45:25.751595Z","shell.execute_reply":"2022-08-10T08:45:25.762382Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['Survived'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:25.765337Z","iopub.execute_input":"2022-08-10T08:45:25.766340Z","iopub.status.idle":"2022-08-10T08:45:25.783095Z","shell.execute_reply.started":"2022-08-10T08:45:25.766280Z","shell.execute_reply":"2022-08-10T08:45:25.780937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['Survived'].value_counts()*100/len(data)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:25.785730Z","iopub.execute_input":"2022-08-10T08:45:25.786890Z","iopub.status.idle":"2022-08-10T08:45:25.801860Z","shell.execute_reply.started":"2022-08-10T08:45:25.786830Z","shell.execute_reply":"2022-08-10T08:45:25.800304Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['Sex'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:25.803991Z","iopub.execute_input":"2022-08-10T08:45:25.804721Z","iopub.status.idle":"2022-08-10T08:45:25.819531Z","shell.execute_reply.started":"2022-08-10T08:45:25.804675Z","shell.execute_reply":"2022-08-10T08:45:25.818127Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['Pclass'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:25.822287Z","iopub.execute_input":"2022-08-10T08:45:25.823291Z","iopub.status.idle":"2022-08-10T08:45:25.837540Z","shell.execute_reply.started":"2022-08-10T08:45:25.823252Z","shell.execute_reply":"2022-08-10T08:45:25.835956Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%matplotlib inline \nalpha_color=0.7\ndata ['Survived'].value_counts().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:25.844055Z","iopub.execute_input":"2022-08-10T08:45:25.845915Z","iopub.status.idle":"2022-08-10T08:45:26.066610Z","shell.execute_reply.started":"2022-08-10T08:45:25.845857Z","shell.execute_reply":"2022-08-10T08:45:26.065351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['Sex'].value_counts().plot(kind='bar',color=['b','r'],alpha=alpha_color)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:26.068105Z","iopub.execute_input":"2022-08-10T08:45:26.069166Z","iopub.status.idle":"2022-08-10T08:45:26.238431Z","shell.execute_reply.started":"2022-08-10T08:45:26.069117Z","shell.execute_reply":"2022-08-10T08:45:26.236711Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['Pclass'].value_counts().sort_index().plot(kind='bar',color=['b','r'],alpha=alpha_color)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:26.240285Z","iopub.execute_input":"2022-08-10T08:45:26.240753Z","iopub.status.idle":"2022-08-10T08:45:26.408780Z","shell.execute_reply.started":"2022-08-10T08:45:26.240708Z","shell.execute_reply":"2022-08-10T08:45:26.407110Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.plot(kind='scatter',x='Survived',y='Age')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:26.410516Z","iopub.execute_input":"2022-08-10T08:45:26.411263Z","iopub.status.idle":"2022-08-10T08:45:26.651752Z","shell.execute_reply.started":"2022-08-10T08:45:26.411224Z","shell.execute_reply":"2022-08-10T08:45:26.650087Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[data['Survived']==1]['Age'].value_counts().sort_index().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:26.653506Z","iopub.execute_input":"2022-08-10T08:45:26.654071Z","iopub.status.idle":"2022-08-10T08:45:27.590455Z","shell.execute_reply.started":"2022-08-10T08:45:26.654035Z","shell.execute_reply":"2022-08-10T08:45:27.589177Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bins=[0,10,20,30,40,50,60,70,80]\ndata['AgeBin']=pd.cut(data['Age'],bins)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:27.592309Z","iopub.execute_input":"2022-08-10T08:45:27.593068Z","iopub.status.idle":"2022-08-10T08:45:27.608944Z","shell.execute_reply.started":"2022-08-10T08:45:27.593019Z","shell.execute_reply":"2022-08-10T08:45:27.607078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[data['Survived']==1]['AgeBin'].value_counts().sort_index().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:27.611043Z","iopub.execute_input":"2022-08-10T08:45:27.611456Z","iopub.status.idle":"2022-08-10T08:45:27.825325Z","shell.execute_reply.started":"2022-08-10T08:45:27.611420Z","shell.execute_reply":"2022-08-10T08:45:27.823756Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bins=[0,10,20,30,40,50,60,70,80]\ndata['AgeBin']=pd.cut(data['Age'],bins)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:27.827800Z","iopub.execute_input":"2022-08-10T08:45:27.828203Z","iopub.status.idle":"2022-08-10T08:45:27.837651Z","shell.execute_reply.started":"2022-08-10T08:45:27.828167Z","shell.execute_reply":"2022-08-10T08:45:27.836108Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['AgeBin'].value_counts().sort_index().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:27.839857Z","iopub.execute_input":"2022-08-10T08:45:27.840423Z","iopub.status.idle":"2022-08-10T08:45:28.017137Z","shell.execute_reply.started":"2022-08-10T08:45:27.840301Z","shell.execute_reply":"2022-08-10T08:45:28.015748Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[data['Pclass']==1]['Survived'].value_counts().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:28.019767Z","iopub.execute_input":"2022-08-10T08:45:28.020136Z","iopub.status.idle":"2022-08-10T08:45:28.191813Z","shell.execute_reply.started":"2022-08-10T08:45:28.020103Z","shell.execute_reply":"2022-08-10T08:45:28.190482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[data['Pclass']==3]['Survived'].value_counts().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:28.193329Z","iopub.execute_input":"2022-08-10T08:45:28.193756Z","iopub.status.idle":"2022-08-10T08:45:28.369923Z","shell.execute_reply.started":"2022-08-10T08:45:28.193719Z","shell.execute_reply":"2022-08-10T08:45:28.368496Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[data['Sex']=='male']['Survived'].value_counts().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:28.371227Z","iopub.execute_input":"2022-08-10T08:45:28.371575Z","iopub.status.idle":"2022-08-10T08:45:28.534868Z","shell.execute_reply.started":"2022-08-10T08:45:28.371523Z","shell.execute_reply":"2022-08-10T08:45:28.533273Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[data['Sex']=='female']['Survived'].value_counts().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:28.537631Z","iopub.execute_input":"2022-08-10T08:45:28.538797Z","iopub.status.idle":"2022-08-10T08:45:28.709034Z","shell.execute_reply.started":"2022-08-10T08:45:28.538750Z","shell.execute_reply":"2022-08-10T08:45:28.707709Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[(data['Sex']=='male')&(data['Pclass']==1)]['Survived'].value_counts().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:28.711153Z","iopub.execute_input":"2022-08-10T08:45:28.711765Z","iopub.status.idle":"2022-08-10T08:45:28.890840Z","shell.execute_reply.started":"2022-08-10T08:45:28.711700Z","shell.execute_reply":"2022-08-10T08:45:28.889670Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[(data['Sex']=='male')&(data['Pclass']==3)]['Survived'].value_counts().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:28.892493Z","iopub.execute_input":"2022-08-10T08:45:28.892907Z","iopub.status.idle":"2022-08-10T08:45:29.064334Z","shell.execute_reply.started":"2022-08-10T08:45:28.892871Z","shell.execute_reply":"2022-08-10T08:45:29.063079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[(data['Sex']=='female')&(data['Pclass']==1)]['Survived'].value_counts().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:29.066093Z","iopub.execute_input":"2022-08-10T08:45:29.066450Z","iopub.status.idle":"2022-08-10T08:45:29.236407Z","shell.execute_reply.started":"2022-08-10T08:45:29.066417Z","shell.execute_reply":"2022-08-10T08:45:29.234969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[(data['Sex']=='female')&(data['Pclass']==3)]['Survived'].value_counts().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:45:29.238317Z","iopub.execute_input":"2022-08-10T08:45:29.238818Z","iopub.status.idle":"2022-08-10T08:45:29.414152Z","shell.execute_reply.started":"2022-08-10T08:45:29.238772Z","shell.execute_reply":"2022-08-10T08:45:29.412653Z"},"trusted":true},"execution_count":null,"outputs":[]}]}