我觉得我很亲密,但是我从列表中读取文件名时遇到了问题。有人可以查看下面的代码并出错并帮助我吗?看起来我在使用列表创建要打开的每个文件名时遇到问题。这是我第一次这样做,所以我有点不知所措。
import pandas as pd
col_names = ['Date','Time','Open','High','Low','Close','Volume','Split Factor','Earnings','Dividends']
SymbolList = []
read = pd.read_csv('/Users/steve/Documents/MATLAB/all_symbols.csv', header=None, delimiter=',')
SymbolList.append(read)
for x in SymbolList:
ticker = x
data = pd.read_csv('/Users/steve/Documents/MATLAB/SNP500 STOCKS 1 MIN DATA/table_' + str(ticker) + '.csv',
header=None, names=col_names, parse_dates=[['Date', 'Time']])
data['Date_Time'] = pd.to_datetime(data.Date_Time.astype(str),format='%Y%m%d %H%M')
data = data.set_index('Date_Time')
data_NormalTradingHours = data.between_time('9:30','16:00')
data_daily = (data_NormalTradingHours.resample('D')
.agg({'Open': 'first', 'High': 'max', 'Low': 'min', 'Close': 'last', 'Volume': 'sum'})).dropna()
data_daily.to_csv('/Users/steve/Documents/MATLAB/SNP500 STOCKS 1 MIN DATA/' + str(ticker) + '_D.csv', sep=',')
这是错误:
FileNotFoundError:文件b' / Users / steve / Documents / MATLAB / SNP500 STOCKS 1 MIN DATA / table_ 0 \ n0 a \ n1 aaba \ n2 aal \ n3 aap \ n4 aapl \ n5 abbv \ n6 abc \ n7 ABI \ n8 ABK \ N9 ABS \ N10 ABT \ N11 ABX \ n12的ACAS \ N13 ack.1 \ N14 ACN \ N15 ACS \ N16 acv.1 \ N17 ADBE \ N18 ADCT \ N19 ADI \ N20 ADM \ N21 ADP \ N22 ADPT .1 \ N23的广告\ N24 ADSK \ N25 ADT \ N26 AEE \ N27 AEP \ N28 AES \ N29 AET \ n ...... \ n998 wm.1 \ n999 WM \ N1000 WMB \ N1001 WMT \ N1002 WMX \ n1003 wor \ n1004 wpx \ n1005 wrk \ n1006 wsh \ n1007 wu \ n1008 wwy \ n1009 wy \ n1010 wye \ n1011 wyn \ n1012 wynn \ n1013 x \ n1014 xec \ n1015 xel \ n1016 xl \ n1017 xlnx \ n1018 xom \ n1019 xray \ n1020 xrx \ n1021 xto \ n1022 xyl \ n1023 ynr \ n1024 yum \ n1025 zbh \ n1026 zion \ n1027 zts \ n \ n [1028行x 1列] .csv'不存在