Replaced sort with sorted

`sort` throws an error, so replaced with `sorted` which solves the same purpose
This commit is contained in:
Jalem Raj Rohit 2016-02-25 19:41:53 +05:30
parent 4e8f427764
commit 176172101d

View File

@ -976,7 +976,7 @@
}
],
"source": [
"sexes = sort(df_train['Sex'].unique())\n",
"sexes = sorted(df_train['Sex'].unique())\n",
"genders_mapping = dict(zip(sexes, range(0, len(sexes) + 1)))\n",
"genders_mapping"
]
@ -1220,7 +1220,7 @@
],
"source": [
"# Get the unique values of Pclass:\n",
"passenger_classes = sort(df_train['Pclass'].unique())\n",
"passenger_classes = sorted(df_train['Pclass'].unique())\n",
"\n",
"for p_class in passenger_classes:\n",
" print 'M: ', p_class, len(df_train[(df_train['Sex'] == 'male') & \n",
@ -1430,7 +1430,7 @@
],
"source": [
"# Get the unique values of Embarked\n",
"embarked_locs = sort(df_train['Embarked'].unique())\n",
"embarked_locs = sorted(df_train['Embarked'].unique())\n",
"\n",
"embarked_locs_mapping = dict(zip(embarked_locs, \n",
" range(0, len(embarked_locs) + 1)))\n",
@ -1682,7 +1682,7 @@
}
],
"source": [
"embarked_locs = sort(df_train['Embarked_Val'].unique())\n",
"embarked_locs = sorted(df_train['Embarked_Val'].unique())\n",
"embarked_locs"
]
},
@ -2393,7 +2393,7 @@
],
"source": [
"# Get the unique values of Embarked and its maximum\n",
"family_sizes = sort(df_train['FamilySize'].unique())\n",
"family_sizes = sorted(df_train['FamilySize'].unique())\n",
"family_size_max = max(family_sizes)\n",
"\n",
"df1 = df_train[df_train['Survived'] == 0]['FamilySize']\n",
@ -2581,7 +2581,7 @@
"def clean_data(df, drop_passenger_id):\n",
" \n",
" # Get the unique values of Sex\n",
" sexes = sort(df['Sex'].unique())\n",
" sexes = sorted(df['Sex'].unique())\n",
" \n",
" # Generate a mapping of Sex from a string to a number representation \n",
" genders_mapping = dict(zip(sexes, range(0, len(sexes) + 1)))\n",
@ -2590,7 +2590,7 @@
" df['Sex_Val'] = df['Sex'].map(genders_mapping).astype(int)\n",
" \n",
" # Get the unique values of Embarked\n",
" embarked_locs = sort(df['Embarked'].unique())\n",
" embarked_locs = sorted(df['Embarked'].unique())\n",
"\n",
" # Generate a mapping of Embarked from a string to a number representation \n",
" embarked_locs_mapping = dict(zip(embarked_locs, \n",