{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "b727536f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "5e9aaf4c",
   "metadata": {},
   "outputs": [],
   "source": [
    "nhl= pd.read_csv('nhl.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "7cb21c8e",
   "metadata": {},
   "outputs": [],
   "source": [
    "wiki= pd.read_csv('cities.csv', skiprows=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "0a27c236",
   "metadata": {},
   "outputs": [],
   "source": [
    "wiki=wiki[['Population\\n(2016 est.)[8]', 'Metropolitan area','NHL']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "b14b101d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nhl.team.isna().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "79d3ef0e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import re\n",
    "import math\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "20db5958",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i, nhl  in enumerate(wiki.NHL):\n",
    "    w=nhl\n",
    "    if '\\n' in nhl:\n",
    "        w=(re.sub( \"\\n\", ' ', nhl))\n",
    "    elif \"—\" in nhl:\n",
    "        w=(re.sub( \"—\", 'NaN', nhl))\n",
    "    wiki.NHL[i]=w\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "c4a2ae07",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wiki.NHL.isna().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "4c25c0f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Population\\n(2016 est.)[8]</th>\n",
       "      <th>Metropolitan area</th>\n",
       "      <th>NHL</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>20,153,634</td>\n",
       "      <td>New York City</td>\n",
       "      <td>Rangers Islanders Devils[note 3]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>13,310,447</td>\n",
       "      <td>Los Angeles</td>\n",
       "      <td>Kings Ducks</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6,657,982</td>\n",
       "      <td>San Francisco Bay Area</td>\n",
       "      <td>Sharks[note 7]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>9,512,999</td>\n",
       "      <td>Chicago</td>\n",
       "      <td>Blackhawks</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7,233,323</td>\n",
       "      <td>Dallas–Fort Worth</td>\n",
       "      <td>Stars</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6,131,977</td>\n",
       "      <td>Washington, D.C.</td>\n",
       "      <td>Capitals</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>6,070,500</td>\n",
       "      <td>Philadelphia</td>\n",
       "      <td>Flyers[note 13]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>4,794,447</td>\n",
       "      <td>Boston</td>\n",
       "      <td>Bruins</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>3,551,036</td>\n",
       "      <td>Minneapolis–Saint Paul</td>\n",
       "      <td>Wild[note 16]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2,853,077</td>\n",
       "      <td>Denver</td>\n",
       "      <td>Avalanche[note 18]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>6,066,387</td>\n",
       "      <td>Miami–Fort Lauderdale</td>\n",
       "      <td>Panthers</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>4,661,537</td>\n",
       "      <td>Phoenix</td>\n",
       "      <td>Coyotes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>4,297,617</td>\n",
       "      <td>Detroit</td>\n",
       "      <td>Red Wings</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>5,928,040</td>\n",
       "      <td>Toronto</td>\n",
       "      <td>Maple Leafs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>6,772,470</td>\n",
       "      <td>Houston</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>5,789,700</td>\n",
       "      <td>Atlanta</td>\n",
       "      <td>[note 25]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>3,032,171</td>\n",
       "      <td>Tampa Bay Area</td>\n",
       "      <td>Lightning</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2,342,299</td>\n",
       "      <td>Pittsburgh</td>\n",
       "      <td>Penguins[note 28]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2,055,612</td>\n",
       "      <td>Cleveland</td>\n",
       "      <td>[note 32]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>3,798,902</td>\n",
       "      <td>Seattle</td>\n",
       "      <td>[note 34]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2,165,139</td>\n",
       "      <td>Cincinnati</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2,104,509</td>\n",
       "      <td>Kansas City</td>\n",
       "      <td>[note 39]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2,807,002</td>\n",
       "      <td>St. Louis</td>\n",
       "      <td>Blues[note 43]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2,798,886</td>\n",
       "      <td>Baltimore</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2,474,314</td>\n",
       "      <td>Charlotte</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2,004,230</td>\n",
       "      <td>Indianapolis</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>1,865,298</td>\n",
       "      <td>Nashville</td>\n",
       "      <td>Predators</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>1,572,482</td>\n",
       "      <td>Milwaukee</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>1,268,883</td>\n",
       "      <td>New Orleans</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>1,132,804</td>\n",
       "      <td>Buffalo</td>\n",
       "      <td>Sabres</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>4,098,927</td>\n",
       "      <td>Montreal</td>\n",
       "      <td>Canadiens</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2,463,431</td>\n",
       "      <td>Vancouver</td>\n",
       "      <td>Canucks</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2,441,257</td>\n",
       "      <td>Orlando</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2,424,955</td>\n",
       "      <td>Portland</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2,041,520</td>\n",
       "      <td>Columbus</td>\n",
       "      <td>Blue Jackets</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>1,392,609</td>\n",
       "      <td>Calgary</td>\n",
       "      <td>Flames</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>1,323,783</td>\n",
       "      <td>Ottawa</td>\n",
       "      <td>Senators</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>1,321,426</td>\n",
       "      <td>Edmonton</td>\n",
       "      <td>Oilers</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>1,186,187</td>\n",
       "      <td>Salt Lake City</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>778,489</td>\n",
       "      <td>Winnipeg</td>\n",
       "      <td>Jets[note 61]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>3,317,749</td>\n",
       "      <td>San Diego</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>2,429,609</td>\n",
       "      <td>San Antonio</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>2,296,418</td>\n",
       "      <td>Sacramento</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>2,155,664</td>\n",
       "      <td>Las Vegas</td>\n",
       "      <td>Golden Knights</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>1,478,212</td>\n",
       "      <td>Jacksonville</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>1,373,211</td>\n",
       "      <td>Oklahoma City</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>1,342,842</td>\n",
       "      <td>Memphis</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>1,302,946</td>\n",
       "      <td>Raleigh</td>\n",
       "      <td>Hurricanes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>318,236</td>\n",
       "      <td>Green Bay</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>747,545</td>\n",
       "      <td>Hamilton</td>\n",
       "      <td>[note 71]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>236,481</td>\n",
       "      <td>Regina</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>–</td>\n",
       "      <td>Totals</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Population\\n(2016 est.)[8]       Metropolitan area  \\\n",
       "0                  20,153,634           New York City   \n",
       "1                  13,310,447             Los Angeles   \n",
       "2                   6,657,982  San Francisco Bay Area   \n",
       "3                   9,512,999                 Chicago   \n",
       "4                   7,233,323       Dallas–Fort Worth   \n",
       "5                   6,131,977        Washington, D.C.   \n",
       "6                   6,070,500            Philadelphia   \n",
       "7                   4,794,447                  Boston   \n",
       "8                   3,551,036  Minneapolis–Saint Paul   \n",
       "9                   2,853,077                  Denver   \n",
       "10                  6,066,387   Miami–Fort Lauderdale   \n",
       "11                  4,661,537                 Phoenix   \n",
       "12                  4,297,617                 Detroit   \n",
       "13                  5,928,040                 Toronto   \n",
       "14                  6,772,470                 Houston   \n",
       "15                  5,789,700                 Atlanta   \n",
       "16                  3,032,171          Tampa Bay Area   \n",
       "17                  2,342,299              Pittsburgh   \n",
       "18                  2,055,612               Cleveland   \n",
       "19                  3,798,902                 Seattle   \n",
       "20                  2,165,139              Cincinnati   \n",
       "21                  2,104,509             Kansas City   \n",
       "22                  2,807,002               St. Louis   \n",
       "23                  2,798,886               Baltimore   \n",
       "24                  2,474,314               Charlotte   \n",
       "25                  2,004,230            Indianapolis   \n",
       "26                  1,865,298               Nashville   \n",
       "27                  1,572,482               Milwaukee   \n",
       "28                  1,268,883             New Orleans   \n",
       "29                  1,132,804                 Buffalo   \n",
       "30                  4,098,927                Montreal   \n",
       "31                  2,463,431               Vancouver   \n",
       "32                  2,441,257                 Orlando   \n",
       "33                  2,424,955                Portland   \n",
       "34                  2,041,520                Columbus   \n",
       "35                  1,392,609                 Calgary   \n",
       "36                  1,323,783                  Ottawa   \n",
       "37                  1,321,426                Edmonton   \n",
       "38                  1,186,187          Salt Lake City   \n",
       "39                    778,489                Winnipeg   \n",
       "40                  3,317,749               San Diego   \n",
       "41                  2,429,609             San Antonio   \n",
       "42                  2,296,418              Sacramento   \n",
       "43                  2,155,664               Las Vegas   \n",
       "44                  1,478,212            Jacksonville   \n",
       "45                  1,373,211           Oklahoma City   \n",
       "46                  1,342,842                 Memphis   \n",
       "47                  1,302,946                 Raleigh   \n",
       "48                    318,236               Green Bay   \n",
       "49                    747,545                Hamilton   \n",
       "50                    236,481                  Regina   \n",
       "51                          –                  Totals   \n",
       "\n",
       "                                 NHL  \n",
       "0   Rangers Islanders Devils[note 3]  \n",
       "1                        Kings Ducks  \n",
       "2                     Sharks[note 7]  \n",
       "3                         Blackhawks  \n",
       "4                              Stars  \n",
       "5                           Capitals  \n",
       "6                    Flyers[note 13]  \n",
       "7                             Bruins  \n",
       "8                      Wild[note 16]  \n",
       "9                 Avalanche[note 18]  \n",
       "10                          Panthers  \n",
       "11                           Coyotes  \n",
       "12                         Red Wings  \n",
       "13                       Maple Leafs  \n",
       "14                               NaN  \n",
       "15                         [note 25]  \n",
       "16                         Lightning  \n",
       "17                 Penguins[note 28]  \n",
       "18                         [note 32]  \n",
       "19                         [note 34]  \n",
       "20                               NaN  \n",
       "21                         [note 39]  \n",
       "22                    Blues[note 43]  \n",
       "23                               NaN  \n",
       "24                               NaN  \n",
       "25                               NaN  \n",
       "26                         Predators  \n",
       "27                               NaN  \n",
       "28                               NaN  \n",
       "29                            Sabres  \n",
       "30                         Canadiens  \n",
       "31                           Canucks  \n",
       "32                               NaN  \n",
       "33                               NaN  \n",
       "34                      Blue Jackets  \n",
       "35                            Flames  \n",
       "36                          Senators  \n",
       "37                            Oilers  \n",
       "38                               NaN  \n",
       "39                     Jets[note 61]  \n",
       "40                               NaN  \n",
       "41                               NaN  \n",
       "42                               NaN  \n",
       "43                    Golden Knights  \n",
       "44                               NaN  \n",
       "45                               NaN  \n",
       "46                               NaN  \n",
       "47                        Hurricanes  \n",
       "48                               NaN  \n",
       "49                         [note 71]  \n",
       "50                               NaN  \n",
       "51                                31  "
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wiki"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c140f59c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9eb2f4d7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a9cd21e8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6760383a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "58f5013b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "adc69220",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d3e634fb",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ac515498",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "38ee3b29",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d230e386",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e1d5631b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c22fc171",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7361f1a7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "705ce2d4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "41ae0bd0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c5dc9fb3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a6ff2df7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2bdb9b59",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "efa933f4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f5e4455c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "93647b7d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4b26e4ff",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
