Question: I was trying to build a scraper to catch league names and odds..Been able to catch the odds but matching the two doesnt seem to work..here is my code:

```
import requests
from bs4 import BeautifulSoup

r = requests.get("http://www.elitebetkenya.com/coupon.php")
soup = BeautifulSoup(r.content)

for i in soup.findAll("tr"):
    tds =  i.findAll("td")
    fixture = soup.findAll("tr", { "class" : "fixture" })

    try:
        if len(tds[0].text)  != 0 :

            print " Bet-type: %s, Choice: %s, Match code: %s, 1: %s, 0:      %s" % \
          (tds[0].text, tds[1].text, tds[2].text,tds[3].text, tds[4].text)
except:
    pass

```

Answer: 
Courtesy of Microsoft Excel: 

[![enter image description here](https://i.stack.imgur.com/8Mbig.png)](https://i.stack.imgur.com/8Mbig.png)
Suppose you have a function:

```
def sinus2d(x, y):
    return np.sin(x) + np.sin(y)

```

and you want, for example, to see what it looks like in the range 0 to 2\*pi. How would you do it? There `np.meshgrid` comes in:

```
xx, yy = np.meshgrid(np.linspace(0,2*np.pi,100), np.linspace(0,2*np.pi,100))
z = sinus2d(xx, yy) # Create the image on this grid

```

and such a plot would look like:

```
import matplotlib.pyplot as plt
plt.imshow(z, origin='lower', interpolation='none')
plt.show()

```

[![enter image description here](https://i.stack.imgur.com/vceRQ.png)](https://i.stack.imgur.com/vceRQ.png)

So `np.meshgrid` is just a convenience. In principle the same could be done by:

```
z2 = sinus2d(np.linspace(0,2*np.pi,100)[:,None], np.linspace(0,2*np.pi,100)[None,:])

```

but there you need to be aware of your dimensions (suppose you have more than two ...) and the right broadcasting. `np.meshgrid` does all of this for you.

Also meshgrid allows you to delete coordinates together with the data if you, for example, want to do an interpolation but exclude certain values:

```
condition = z>0.6
z_new = z[condition] # This will make your array 1D

```

so how would you do the interpolation now? You can give `x` and `y` to an interpolation function like `scipy.interpolate.interp2d` so you need a way to know which coordinates were deleted:

```
x_new = xx[condition]
y_new = yy[condition]

```

and then you can still interpolate with the "right" coordinates (try it without the meshgrid and you will have a lot of extra code):

```
from scipy.interpolate import interp2d
interpolated = interp2d(x_new, y_new, z_new)

```

and the original meshgrid allows you to get the interpolation on the original grid again:

```
interpolated_grid = interpolated(xx[0], yy[:, 0]).reshape(xx.shape)

```

These are just some examples where I used the `meshgrid` there might be a lot more.