{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"222ffd3df2a1aec2c33fdf14a2054828f959e990"},"cell_type":"code","source":"import pandas as pd \ndf = pd.DataFrame([\n  [1, 'San Diego', 100],\n  [2, 'Los Angeles', 120],\n  [3, 'San Francisco', 90],\n  [4, 'Sacramento', 115],\n],\n  columns=[\n    'Store ID',\n    'Location',\n    'Number of Employees',\n  ])\n\nprint(df)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7215f9e304a62cb5d22eb5b1ba4f1a3d13cf794b"},"cell_type":"code","source":"df.to_csv('../input/new-csv-file.csv')","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"df = pd.read_csv(\"../input/train.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b523c37f1266546839e13bc193ffcc816370b942"},"cell_type":"code","source":"df","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"89776d213192c1a08090538844dbaa650759d969"},"cell_type":"code","source":"df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"47039d8a29723656a0f91394e499cbdf5a7fe15f"},"cell_type":"code","source":"df.info()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8553325a49be9e2a9d90999b3bdd9804d9306964"},"cell_type":"code","source":"df.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2c8ec8b27cd80289fb7cfc5a0f38c415d8d095c3"},"cell_type":"code","source":"df.columns","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b0017e698f467a52bc8910a327f58fa3a26dbe7c"},"cell_type":"code","source":"df[['Name','Sex']].head(10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a704b2eecf5b6f748d830998693610cb6e7456b6"},"cell_type":"code","source":"df['Sex'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"24757f18d9922d8957cf26e8f8ebf8ec763cddf2"},"cell_type":"code","source":"df['Pclass'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6cba2a5529d6655d1ff8780e9dda7305067a50cf"},"cell_type":"code","source":"df['Age'].mean()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2e1a26b4c248059059db07f26e819a6e83efef32"},"cell_type":"code","source":"#max min mean of fare col\ndf['Fare'].max()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6369628b8f3c896bf8cf3f4c1a963cf38b6246bf"},"cell_type":"code","source":"df['Fare'].min()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"bd6787408bd115f4e62871519478037ad7b33c30"},"cell_type":"code","source":"df['Fare'].mean()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4e623ad4655e5897d8b658c00dfb74b8c846c5d9"},"cell_type":"code","source":"#each embarked\ndf['Embarked'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"601084ba98eab74f7d77fd219a62df522c0010e0"},"cell_type":"code","source":"len(df)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"fa44c7035b08def51201cf4b8b72c5c7d5c171f5"},"cell_type":"code","source":"male_df = df[df['Sex']=='male']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8f9d646ed060ef5b2ea8e208b381da29076f639e"},"cell_type":"code","source":"len(male_df)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f1cd2cbf0e188971694a5fae8053a63e7b68e375"},"cell_type":"code","source":"df_age_above_50 = df[(df['Age'] > 50) & (df['Sex']=='male')]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"eb800fe23c25509aff6d12b8d634723fff7de21c"},"cell_type":"code","source":"#no of m and f btw age 30 and 50\ndf_male_female_btw_age_30_and_50 = df[(50>df['Age']) & (df['Age']>30)]\ndf_male_female_btw_age_30_and_50","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e396fc22825ef6b133f1aca906e2e068143d847b"},"cell_type":"code","source":"#no of f with embarked val as s\ndf_female_emarked_as_s = df[(df['Sex']=='female') & (df['Embarked']=='S')]\ndf_female_emarked_as_s","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9c18029ccaf0415063176e687b5adafbfdc09927"},"cell_type":"code","source":"#select 1st row\ndf.iloc[0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b0e848c913b8d4d0a756eac0143b8ef3e74a7cbd"},"cell_type":"code","source":"df.Location.isin(['San Diego','Los Angeles'])","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}