王的机器-盘一盘python系列-debug日志

    科技2024-03-31  95

    王的机器

    盘一盘python系列

    Matplotlab

    使用pdb debug

    写了数据格式转换函数

    def data_converter( price_data, code, asset ): # convert raw data to datafram if asset =='FX': # what's FX code = str(code[3:] if code[:3]=='USD' else code) + '=X' columns = [ 'open', 'close', 'low', 'high' ] price_dict = price_data[code]['prices'] index = [ p['formatted_date'] for p in price_dict ] price = [ [p[c] for c in columns] for p in price_dict ] data = pd.DataFrame( price, index=pd.Index(index, name='date'), columns=pd.Index(columns, name='OHLC') ) return data

    之后运行:

    NVDA = data_converter( stock_daily, 'NVDA', 'EQ' ) NVDA.head(3).append(NVDA.tail(3))

    报错: 之后使用pdb进行debug

    一直没有读懂这是什么意思,难道是运行了这个 if 之后就直接return了?不应该呀。在pycharm中进行了debug,确定是运行了这一句之后就直接跳出来了。对照原来的代码,是缩进的问题。

    Processed: 0.018, SQL: 8