Skip to content

Commit

Permalink
Created using Colaboratory
Browse files Browse the repository at this point in the history
  • Loading branch information
southjohn64 committed Oct 31, 2021
1 parent ac76ced commit 9eafed4
Showing 1 changed file with 53 additions and 17 deletions.
70 changes: 53 additions & 17 deletions HW_2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@
{
"cell_type": "code",
"metadata": {
"id": "v5NWpk8sx9BT",
"outputId": "90f440eb-096f-429d-d61e-333e1eb833e9",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"id": "v5NWpk8sx9BT",
"outputId": "90f440eb-096f-429d-d61e-333e1eb833e9"
},
"source": [
"from google.colab import drive\n",
Expand All @@ -244,11 +244,11 @@
{
"cell_type": "code",
"metadata": {
"id": "VjmQ5hWOx_QO",
"outputId": "24f4f47e-d1a7-445a-d77f-8bda7ba5dd22",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"id": "VjmQ5hWOx_QO",
"outputId": "24f4f47e-d1a7-445a-d77f-8bda7ba5dd22"
},
"source": [
"import json\n",
Expand Down Expand Up @@ -311,11 +311,11 @@
{
"cell_type": "code",
"metadata": {
"id": "XpdIMnqxyCa7",
"outputId": "55e1b0fa-e7c2-4151-b715-2f86cfbc12c1",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"id": "XpdIMnqxyCa7",
"outputId": "55e1b0fa-e7c2-4151-b715-2f86cfbc12c1"
},
"source": [
"# Creating a dataset directory\n",
Expand Down Expand Up @@ -343,12 +343,12 @@
{
"cell_type": "code",
"metadata": {
"id": "Ifgyk4SVy0gg",
"outputId": "24e480aa-e923-487a-8847-4edcf56df3fc",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 204
}
},
"id": "Ifgyk4SVy0gg",
"outputId": "24e480aa-e923-487a-8847-4edcf56df3fc"
},
"source": [
"\n",
Expand Down Expand Up @@ -446,14 +446,24 @@
"id": "gYIoTJNIifX8"
},
"source": [
"hero_dic = {}\n",
"hero_1_2_dic = {}\n",
"new_df = {'hero1':[] , 'hero2':[]}\n",
"for index, row1 in df.iterrows():\n",
" hero1 = row1['hero1']\n",
" hero2 = row1['hero2']\n",
" if \"hero1\" not in hero_dic:\n",
" hero_dic[hero1]=[]\n",
" hero_dic[hero1].append(hero2)\n",
" if hero1 not in hero_1_2_dic:\n",
" hero_1_2_dic[hero1]=[]\n",
" hero_1_2_dic[hero1].append(hero2)\n",
"\n",
"\n",
"hero_2_1_dic = {}\n",
"#new_df = {'hero1':[] , 'hero2':[]}\n",
"for index, row1 in df.iterrows():\n",
" hero1 = row1['hero1']\n",
" hero2 = row1['hero2']\n",
" if hero2 not in hero_2_1_dic:\n",
" hero_2_1_dic[hero2]=[]\n",
" hero_2_1_dic[hero2].append(hero1)\n",
" \n",
" # for index, row2 in df.copy().iterrows():\n",
" # copy_hero1 = row2['hero1']\n",
Expand All @@ -463,9 +473,35 @@
" #new_df['hero1'].append(hero1)\n",
" "
],
"execution_count": null,
"execution_count": 15,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "7BICMJM011PE",
"outputId": "33c224bf-fd7f-4dde-fea0-cd596bef6b96"
},
"source": [
" for item in hero_1_2_dic.items():\n",
" print(item)\n",
" break\n",
"\n"
],
"execution_count": 16,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"('LITTLE, ABNER', ['PRINCESS ZANDA'])\n"
]
}
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down

0 comments on commit 9eafed4

Please sign in to comment.