Python - ufunc 'add' did not contain a loop with signature matching types dtype('<U77') dtype('<U77') dtype('

 
Vista:

ufunc 'add' did not contain a loop with signature matching types dtype('<U77') dtype('<U77') dtype('

Publicado por Fabricio (1 intervención) el 31/07/2018 20:15:41
Hola estoy intentando hacer un programa para descargar datos de una pagina web sin tener que hacerlo manualmente, estoy utilizando el siguiente script pero algo no está funcionando puesto que recibo ese error y no lo entiendo. Alguien sabe cómo solucionarlo o explicarme cuál es el error?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import numpy as np
import urllib.request as urllib2
from bs4 import BeautifulSoup
 
año = np.arange(1960, 2017,1)
mes = np.arange(1,13)
dia = np.arange(1,32)
hora = np.arange(1,25)
stn = '78954' #estación meteorológica
 
for i in  np.nditer(año):
    for j in  np.nditer(mes):
        for k in  np.nditer(dia):
            url = 'http://weather.uwyo.edu/cgi-bin/sounding?region=naconf&TYPE=TEXT%3ALIST&YEAR='+año+'&MONTH='+mes+'&FROM='+dia+hora+'&TO='+dia+hora+'&STNM='+stn
            content = urllib2.urlopen(url).read()
            soup = BeautifulSoup(content)
            data_text = soup.get_text()
            splitted = data_text.split("\n",data_text.count("\n"))
            Sounding_filename = str(stn)+'.'+str(año)+str(mes)+str(dia)+str(hora)+'.txt'
            f = open(Sounding_filename,'w')
            for line in splitted[4:]:
                f.write(line+'\n')
                f.close()
TypeError                                 Traceback (most recent call last)
<ipython-input-9-33d4330c2f14> in <module>()
      2     for j in  np.nditer(mes):
      3         for k in  np.nditer(dia):
----> 4             url = 'http://weather.uwyo.edu/cgi-bin/sounding?region=naconf&TYPE=TEXT%3ALIST&YEAR='+año+'&MONTH='+mes+'&FROM='+dia+hora+'&TO='+dia+hora+'&STNM='+stn
      5             content = urllib2.urlopen(url).read()
      6             soup = BeautifulSoup(content)
 
TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U77') dtype('<U77') dtype('<U77')
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder