|

楼主 |
发表于 2024-11-7 17:06:03
|
显示全部楼层
- pd.concat([result.astype(np.float32),y_valid],axis=1)#两个数组合并成一个dataframe
复制代码
有报错- ---------------------------------------------------------------------------
- TypeError Traceback (most recent call last)
- Cell In[83], line 1
- ----> 1 pd.concat([result.values,y_valid],axis=1)#两个数组合并成一个dataframe
- File /opt/conda/lib/python3.10/site-packages/pandas/core/reshape/concat.py:382, in concat(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy)
- 379 elif copy and using_copy_on_write():
- 380 copy = False
- --> 382 op = _Concatenator(
- 383 objs,
- 384 axis=axis,
- 385 ignore_index=ignore_index,
- 386 join=join,
- 387 keys=keys,
- 388 levels=levels,
- 389 names=names,
- 390 verify_integrity=verify_integrity,
- 391 copy=copy,
- 392 sort=sort,
- 393 )
- 395 return op.get_result()
- File /opt/conda/lib/python3.10/site-packages/pandas/core/reshape/concat.py:448, in _Concatenator.__init__(self, objs, axis, join, keys, levels, names, ignore_index, verify_integrity, copy, sort)
- 445 objs, keys = self._clean_keys_and_objs(objs, keys)
- 447 # figure out what our result ndim is going to be
- --> 448 ndims = self._get_ndims(objs)
- 449 sample, objs = self._get_sample_object(objs, ndims, keys, names, levels)
- 451 # Standardize axis parameter to int
- File /opt/conda/lib/python3.10/site-packages/pandas/core/reshape/concat.py:489, in _Concatenator._get_ndims(self, objs)
- 484 if not isinstance(obj, (ABCSeries, ABCDataFrame)):
- 485 msg = (
- 486 f"cannot concatenate object of type '{type(obj)}'; "
- 487 "only Series and DataFrame objs are valid"
- 488 )
- --> 489 raise TypeError(msg)
- 491 ndims.add(obj.ndim)
- 492 return ndims
- TypeError: cannot concatenate object of type '<class 'builtin_function_or_method'>'; only Series and DataFrame objs are valid
复制代码
result是一个张量,如何转化成series |
|