无法在 Pandas 中保存值

Not able to save values in Pandas

我能够看到收报机收到了数据,但我无法将其写入 pandas 文件 df

stock_data = []
with open('Nifty 50 Scrapped data.csv') as csvfile:
    stockticker_data = csv.reader(csvfile, delimiter=' ')
    for row in stockticker_data:
        print(row)

        for ticker in row:
            stock_data.append(web.get_data_yahoo(ticker, '1/1/2018', '1/1/2019'))
            # stock_data.append(all_data)
            df = pd.DataFrame(stock_data)
            print(df)

如果我 print(stock_data) 而不是 print(df) 我得到以下输出:

['ASIANPAINT.NS']
[                   High          Low  ...     Volume    Adj Close
Date                                  ...                        
2018-01-01  1165.000000  1138.099976  ...   591349.0  1129.451782
2018-01-02  1150.000000  1134.050049  ...   516171.0  1128.562866
2018-01-03  1149.000000  1135.300049  ...   593809.0  1127.723511
2018-01-04  1178.000000  1145.900024  ...   729965.0  1157.499146
2018-01-05  1192.000000  1167.449951  ...  1151320.0  1170.535278
...                 ...          ...  ...        ...          ...
2018-12-27  1384.750000  1354.300049  ...  2174090.0  1365.134155
2018-12-28  1383.000000  1359.000000  ...  1705033.0  1358.669067
2018-12-31  1378.000000  1367.300049  ...   698593.0  1365.681274
2019-01-01  1379.699951  1358.599976  ...   664707.0  1364.189331
2019-01-02  1386.849976  1361.599976  ...  1233780.0  1375.876221

[248 rows x 6 columns]]
['AXISBANK.NS']
[                   High          Low  ...     Volume    Adj Close
Date                                  ...                        
2018-01-01  1165.000000  1138.099976  ...   591349.0  1129.451782
2018-01-02  1150.000000  1134.050049  ...   516171.0  1128.562866
2018-01-03  1149.000000  1135.300049  ...   593809.0  1127.723511
2018-01-04  1178.000000  1145.900024  ...   729965.0  1157.499146
2018-01-05  1192.000000  1167.449951  ...  1151320.0  1170.535278
...                 ...          ...  ...        ...          ...
2018-12-27  1384.750000  1354.300049  ...  2174090.0  1365.134155
2018-12-28  1383.000000  1359.000000  ...  1705033.0  1358.669067
2018-12-31  1378.000000  1367.300049  ...   698593.0  1365.681274
2019-01-01  1379.699951  1358.599976  ...   664707.0  1364.189331
2019-01-02  1386.849976  1361.599976  ...  1233780.0  1375.876221

这是我想要的,但是 df = pd.DataFrame(stock_data) print(df) 的输出是

['ASIANPAINT.NS']
                                                   0
0                     High          Low  ...     ...
['AXISBANK.NS']
                                                   0
0                     High          Low  ...     ...
1                    High         Low  ...    Vol...
['BAJAJ-AUTO.NS']
                                                   0
0                     High          Low  ...     ...
1                    High         Low  ...    Vol...
2                     High          Low  ...    V...

为什么这里没有显示数据?

stock_data = []
with open('Nifty 50 Scrapped data.csv') as csvfile:
    stockticker_data = csv.reader(csvfile, delimiter=' ')
    for row in stockticker_data:
        print(row)

        for ticker in row:
            stock_data.append(web.get_data_yahoo(ticker,'1/1/2018','1/1/2019'))
            # stock_data.append(all_data)
df = pd.DataFrame(stock_data)
print(df)

试试这个,也许那个循环会弄乱你的 df