目录
一、问题
就是打印dataframe出的错,完整报错截图如下:
Traceback (most recent call last):
File "/root/anaconda3/lib/python3.8/site-packages/flask/app.py", line 2551, in __call__
return self.wsgi_app(environ, start_response)
File "/root/anaconda3/lib/python3.8/site-packages/flask/app.py", line 2531, in wsgi_app
response = self.handle_exception(e)
File "/root/anaconda3/lib/python3.8/site-packages/flask/app.py", line 2528, in wsgi_app
response = self.full_dispatch_request()
File "/root/anaconda3/lib/python3.8/site-packages/flask/app.py", line 1825, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/root/anaconda3/lib/python3.8/site-packages/flask/app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "/root/anaconda3/lib/python3.8/site-packages/flask/app.py", line 1799, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/zqykj/finance/rule_recommend/rule_recommed_run.py", line 284, in run
return_rule_info = tree_decide(x,dtree,final_result,white_all_count,black_all_count,recall_condition)
File "/usr/local/zqykj/finance/rule_recommend/rule_recommed_run.py", line 214, in tree_decide
print(rule_detail_df)
File "/root/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py", line 744, in __repr__
self.to_string(
File "/root/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py", line 883, in to_string
return formatter.to_string(buf=buf, encoding=encoding)
File "/root/anaconda3/lib/python3.8/site-packages/pandas/io/formats/format.py", line 921, in to_string
return self.get_result(buf=buf, encoding=encoding)
File "/root/anaconda3/lib/python3.8/site-packages/pandas/io/formats/format.py", line 520, in get_result
self.write_result(buf=f)
File "/root/anaconda3/lib/python3.8/site-packages/pandas/io/formats/format.py", line 844, in write_result
max_len = Series(lines).str.len().max()
File "/root/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py", line 11474, in stat_func
return self._reduce(
File "/root/anaconda3/lib/python3.8/site-packages/pandas/core/series.py", line 4249, in _reduce
return op(delegate, skipna=skipna, **kwds)
File "/root/anaconda3/lib/python3.8/site-packages/pandas/core/nanops.py", line 120, in f
result = bn_func(values, axis=axis, **kwds)
TypeError: 'NoneType' object is not callable
可以看到,出错的是这一行:print(rule_detail_df)。
二、问题解决
添加以下两行代码即可(来源于网上)
pd.set_option('display.max_columns', None) # 展示所有列
pd.set_option('display.max_rows', None) # 显示所有行
文章评论