Skip to content

Commit 1761721

Browse files
author
Jalem Raj Rohit
committed
Replaced sort with sorted
`sort` throws an error, so replaced with `sorted` which solves the same purpose
1 parent 4e8f427 commit 1761721

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kaggle/titanic.ipynb

+7-7
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@
976976
}
977977
],
978978
"source": [
979-
"sexes = sort(df_train['Sex'].unique())\n",
979+
"sexes = sorted(df_train['Sex'].unique())\n",
980980
"genders_mapping = dict(zip(sexes, range(0, len(sexes) + 1)))\n",
981981
"genders_mapping"
982982
]
@@ -1220,7 +1220,7 @@
12201220
],
12211221
"source": [
12221222
"# Get the unique values of Pclass:\n",
1223-
"passenger_classes = sort(df_train['Pclass'].unique())\n",
1223+
"passenger_classes = sorted(df_train['Pclass'].unique())\n",
12241224
"\n",
12251225
"for p_class in passenger_classes:\n",
12261226
" print 'M: ', p_class, len(df_train[(df_train['Sex'] == 'male') & \n",
@@ -1430,7 +1430,7 @@
14301430
],
14311431
"source": [
14321432
"# Get the unique values of Embarked\n",
1433-
"embarked_locs = sort(df_train['Embarked'].unique())\n",
1433+
"embarked_locs = sorted(df_train['Embarked'].unique())\n",
14341434
"\n",
14351435
"embarked_locs_mapping = dict(zip(embarked_locs, \n",
14361436
" range(0, len(embarked_locs) + 1)))\n",
@@ -1682,7 +1682,7 @@
16821682
}
16831683
],
16841684
"source": [
1685-
"embarked_locs = sort(df_train['Embarked_Val'].unique())\n",
1685+
"embarked_locs = sorted(df_train['Embarked_Val'].unique())\n",
16861686
"embarked_locs"
16871687
]
16881688
},
@@ -2393,7 +2393,7 @@
23932393
],
23942394
"source": [
23952395
"# Get the unique values of Embarked and its maximum\n",
2396-
"family_sizes = sort(df_train['FamilySize'].unique())\n",
2396+
"family_sizes = sorted(df_train['FamilySize'].unique())\n",
23972397
"family_size_max = max(family_sizes)\n",
23982398
"\n",
23992399
"df1 = df_train[df_train['Survived'] == 0]['FamilySize']\n",
@@ -2581,7 +2581,7 @@
25812581
"def clean_data(df, drop_passenger_id):\n",
25822582
" \n",
25832583
" # Get the unique values of Sex\n",
2584-
" sexes = sort(df['Sex'].unique())\n",
2584+
" sexes = sorted(df['Sex'].unique())\n",
25852585
" \n",
25862586
" # Generate a mapping of Sex from a string to a number representation \n",
25872587
" genders_mapping = dict(zip(sexes, range(0, len(sexes) + 1)))\n",
@@ -2590,7 +2590,7 @@
25902590
" df['Sex_Val'] = df['Sex'].map(genders_mapping).astype(int)\n",
25912591
" \n",
25922592
" # Get the unique values of Embarked\n",
2593-
" embarked_locs = sort(df['Embarked'].unique())\n",
2593+
" embarked_locs = sorted(df['Embarked'].unique())\n",
25942594
"\n",
25952595
" # Generate a mapping of Embarked from a string to a number representation \n",
25962596
" embarked_locs_mapping = dict(zip(embarked_locs, \n",

0 commit comments

Comments
 (0)