Python 3
我需要使用这个数据网站绘制从 8 月 3 日到 8 月 10 日的臭氧时间序列。我需要将数据"拼接"在一起。
http://skywatch.colorado.edu/data/ozone_18_09_03.dat 所以现在我有
pre= 'http://skywatch.colorado.edu/data/ozone_18_09_0'
ozone = []
utc = []
dates = np.arange(3,10,1)
for date in dates:
url = pre + dates[i] + ".dat"
lines = urllib.request.urlopen(url).readlines()
for line in lines: #for x number of times (however many lines appear in the dataset)
entries = line.decode("utf-8").split("t")
if entries[0][0] != ';': #if there are entries that do not have a semicolon
utc.append(float(entries[0][0:2]) +
float(entries[0][3:5])/60. +
float(entries[0][6:8])/3600.)
#converts the UTC time variable into a float and adds it to the list 'utc'
ozone.append(float(entries[1]))
当我尝试运行它时,出现错误
----> 9 网址 = pre + date[i] + ".dat">
类型错误:必须是 str,而不是 numpy.int32 注意确定如何处理这个问题
我认为您可能需要将numpy.int32对象显式转换为字符串,因为numpy很可能没有为other: str
定义__add__(self, other)
。
此外,您正在使用变量date
遍历dates
,因此您将使用如下所示的内容:
url = pre + str(date) + ".dat"