I am trying to scrape a table from wikipedia using Beautifulsoup into my python notebook but I am unable to get my desired result.
I'm trying to convert the wikipedia table here
to this format in python

I have tried the python code below code but it is not giving me the required output. How else can I achieve this please?
source = requests.get('https://en.wikipedia.org/wiki/List_of_postal_codes_of_Canada:_M').text
soup=BeautifulSoup(source,'lxml')
print(soup.title)
from IPython.display import display_html
tab = str(soup.table)
display_html(tab,raw=True)