1
0
mirror of https://github.com/gsi-upm/sitc synced 2024-11-22 06:22:29 +00:00

Added substrings_in_string

This commit is contained in:
Carlos A. Iglesias 2016-04-12 16:42:51 +02:00
parent 1f7f6b68ae
commit 68f405d91d

View File

@ -443,6 +443,12 @@
},
"outputs": [],
"source": [
"def substrings_in_string(big_string, substrings):\n",
"for substring in substrings:\n",
" if big_string.find(substring) != 1:\n",
" return substring\n",
"print(big_string)\n",
"return np.nan\n",
"#Turning cabin number into Deck\n",
"cabin_list = ['A', 'B', 'C', 'D', 'E', 'F', 'T', 'G', 'Unknown']\n",
"df['Deck']=df['Cabin'].map(lambda x: substrings_in_string(x, cabin_list))"