Jupyter笔记本在终端中显示输出

时间:2019-05-29 09:49:40

标签: python terminal module jupyter-notebook jupyter

我正在使用Jupyter笔记本,但是当我尝试通过简单地给出变量名并按Shift + Enter而不是在笔记本中(单元格旁边)获取输出来打印某些东西以获取任何输出时,我得到了在我启动笔记本电脑的终端中找到它。我想查看笔记本本身的输出,并最终将数据存储为数据框并导出为csv。

代码:

from multiprocessing import Process, Pool
import datetime
import time
import worker

start = time.time()

if __name__ ==  '__main__': 
  pool = []
  numdays = 365
  start_date = datetime.datetime(2019, 1, 15 )  #year - month - day
  datelist = [
        (start_date - datetime.timedelta(days=x)).strftime('%Y%m%d') for x in 
        range(0, numdays)
        ]

pool = Pool(processes=16)
pool.map(worker.load, datelist)

pool.close()
pool.join()

和工作程序模块

import pandas as pd
import datetime
import urllib
import requests
from pprint import pprint
import time
from io import StringIO

symbols = ['AAP']
start = time.time()
dflist = []

def load(date):
    if date is None:
        return
    url = "http://regsho.finra.org/FNYXshvol{}.txt".format(date)
    try:
        df = pd.read_csv(url,delimiter='|')
        if any(df['Symbol'].isin(symbols)):
            stocks = df[df['Symbol'].isin(symbols)]
            print(stocks.to_string(index=False, header=False))
            # Save stocks to mysql
        else:
            print(f'No stock found for {date}' )
    except urllib.error.HTTPError:
        pass

The results in the terminal are as follows

我希望能够简单地将此数据作为数据框。 我怀疑这是由于Jupyter笔记本模块出现问题。

0 个答案:

没有答案