Python problem - printing DataFrame error (TypeError: 'NoneType' object is not callable)

Table of contents

1. Problems

2. Problem solving


1. Problems

        It is the error of printing the dataframe. The screenshot of the complete error report is as follows:

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

        As you can see, the error is this line: print(rule_detail_df).

2. Problem solving

        Just add the following two lines of code (from the Internet)

pd.set_option('display.max_columns', None) # 展示所有列
pd.set_option('display.max_rows', None) # 显示所有行

Guess you like

Origin blog.csdn.net/zkkkkkkkkkkkkk/article/details/130137580