创建无反射的对象

时间:2018-11-06 13:56:50

标签: java generics

我有这个方法存根:

'list' object has no attribute 'equals'

如何创建无反射的trd_exctn_dt trd_exctn_tm contra_party_type ascii_rptd_vol_tx rptd_pr yld_pt side sttl_dt msg_seq_nb 0 2018-07-02 9:35:21 D 250000.0 98.623000 4.475237 S 7/5/2018 4418 1 2018-07-02 9:39:08 D 150000.0 98.610000 4.476914 S 7/5/2018 4747 `--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj) 700 type_pprinters=self.type_printers, 701 deferred_pprinters=self.deferred_printers) --> 702 printer.pretty(obj) 703 printer.flush() 704 return stream.getvalue() ~\Anaconda3\lib\site-packages\IPython\lib\pretty.py in pretty(self, obj) 398 if cls is not object \ 399 and callable(cls.__dict__.get('__repr__')): --> 400 return _repr_pprint(obj, self, cycle) 401 402 return _default_pprint(obj, self, cycle) ~\Anaconda3\lib\site-packages\IPython\lib\pretty.py in _repr_pprint(obj, p, cycle) 693 """A pprint that just redirects to the normal repr function.""" 694 # Find newlines and replace them with p.break_() --> 695 output = repr(obj) 696 for idx,output_line in enumerate(output.splitlines()): 697 if idx: ~\Anaconda3\lib\site-packages\pandas\core\base.py in __repr__(self) 80 Yields Bytestring in Py2, Unicode String in py3. 81 """ ---> 82 return str(self) 83 84 ~\Anaconda3\lib\site-packages\pandas\core\base.py in __str__(self) 59 60 if compat.PY3: ---> 61 return self.__unicode__() 62 return self.__bytes__() 63 ~\Anaconda3\lib\site-packages\pandas\core\frame.py in __unicode__(self) 661 width = None 662 self.to_string(buf=buf, max_rows=max_rows, max_cols=max_cols, --> 663 line_width=width, show_dimensions=show_dimensions) 664 665 return buf.getvalue() ~\Anaconda3\lib\site-packages\pandas\core\frame.py in to_string(self, buf, columns, col_space, header, index, na_rep, formatters, float_format, sparsify, index_names, justify, line_width, max_rows, max_cols, show_dimensions) 1965 max_rows=max_rows, 1966 max_cols=max_cols, -> 1967 show_dimensions=show_dimensions) 1968 formatter.to_string() 1969 ~\Anaconda3\lib\site-packages\pandas\io\formats\format.py in __init__(self, frame, buf, columns, col_space, header, index, na_rep, formatters, justify, float_format, sparsify, index_names, line_width, max_rows, max_cols, show_dimensions, decimal, table_id, **kwds) 430 self.columns = frame.columns 431 --> 432 self._chk_truncate() 433 self.adj = _get_adjustment() 434 ~\Anaconda3\lib\site-packages\pandas\io\formats\format.py in _chk_truncate(self) 502 row_num = max_rows_adj // 2 503 frame = concat((frame.iloc[:row_num, :], --> 504 frame.iloc[-row_num:, :])) 505 self.tr_row_num = row_num 506 ~\Anaconda3\lib\site-packages\pandas\core\reshape\concat.py in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names, verify_integrity, sort, copy) 224 verify_integrity=verify_integrity, 225 copy=copy, sort=sort) --> 226 return op.get_result() 227 228 ~\Anaconda3\lib\site-packages\pandas\core\reshape\concat.py in get_result(self) 414 415 obj_labels = mgr.axes[ax] --> 416 if not new_labels.equals(obj_labels): 417 indexers[ax] = obj_labels.reindex(new_labels)[1] 418 AttributeError: 'list' object has no attribute 'equals' --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj) 343 method = get_real_method(obj, self.print_method) 344 if method is not None: --> 345 return method() 346 return None 347 else: ~\Anaconda3\lib\site-packages\pandas\core\frame.py in _repr_html_(self) 694 695 return self.to_html(max_rows=max_rows, max_cols=max_cols, --> 696 show_dimensions=show_dimensions, notebook=True) 697 else: 698 return None ~\Anaconda3\lib\site-packages\pandas\core\frame.py in to_html(self, buf, columns, col_space, header, index, na_rep, formatters, float_format, sparsify, index_names, justify, bold_rows, classes, escape, max_rows, max_cols, show_dimensions, notebook, decimal, border, table_id) 2030 max_cols=max_cols, 2031 show_dimensions=show_dimensions, -> 2032 decimal=decimal, table_id=table_id) 2033 # TODO: a generic formatter wld b in DataFrameFormatter 2034 formatter.to_html(classes=classes, notebook=notebook, border=border) ~\Anaconda3\lib\site-packages\pandas\io\formats\format.py in __init__(self, frame, buf, columns, col_space, header, index, na_rep, formatters, justify, float_format, sparsify, index_names, line_width, max_rows, max_cols, show_dimensions, decimal, table_id, **kwds) 430 self.columns = frame.columns 431 --> 432 self._chk_truncate() 433 self.adj = _get_adjustment() 434 ~\Anaconda3\lib\site-packages\pandas\io\formats\format.py in _chk_truncate(self) 502 row_num = max_rows_adj // 2 503 frame = concat((frame.iloc[:row_num, :], --> 504 frame.iloc[-row_num:, :])) 505 self.tr_row_num = row_num 506 ~\Anaconda3\lib\site-packages\pandas\core\reshape\concat.py in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names, verify_integrity, sort, copy) 224 verify_integrity=verify_integrity, 225 copy=copy, sort=sort) --> 226 return op.get_result() 227 228 ~\Anaconda3\lib\site-packages\pandas\core\reshape\concat.py in get_result(self) 414 415 obj_labels = mgr.axes[ax] --> 416 if not new_labels.equals(obj_labels): 417 indexers[ax] = obj_labels.reindex(new_labels)[1] 418 AttributeError: 'list' object has no attribute 'equals'` 对象?

1 个答案:

答案 0 :(得分:3)

不能。仅仅有了Class<T>,您就已经在使用反射了。

在Java中,类T可以来自与您的代码分开编译的库(较早或较晚)。这意味着必须使用该类的运行时表示形式来创建实例。

据我所知,C ++确实允许非反射式实例化,但是您需要使用外部库的头文件重新编译代码以使其正常工作,因此使您的代码依赖于所讨论的库。< / p>