我将goog.npz文件保存在下面建议的目录中,而不是将其保存在这里:
file_path ='C:/ Users /.../ goog.npz'
,然后用r(在下面)替换为读取存储位置文件的内容。感谢您的帮助!
# Load a numpy record array from yahoo csv data with fields date, open, close,
# volume, adj_close from the mpl-data/example directory. The record array
# stores the date as an np.datetime64 with a day unit ('D') in the date column.
with cbook.get_sample_data('goog.npz') as datafile:
r = np.load(datafile)['price_data'].view(np.recarray)
答案 0 :(得分:0)
只需使用get_sample_data
方法指定文件的整个路径:
with cbook.get_sample_data('C:Users/.../goog.npz') as datafile:
r = np.load(datafile)['price_data'].view(np.recarray)