numpy.concatenate()
Official Documentation Link
Function Description.
Join a sequence of arrays along an existing axis.
Join a sequence of arrays along an existing axis.
Program error
KeyError Traceback (most recent call last)
F:\Anacondaaa\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3079 try:
-> 3080 return self._engine.get_loc(casted_key)
3081 except KeyError as err:
pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
KeyError: 0
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
in
—-> 1 np.unique(np.concatenate(movie_type[‘类型’].map(lambda x: x.split(’/’))))
<array_function internals> in concatenate(*args, **kwargs)
F:\Anacondaaa\lib\site-packages\pandas\core\series.py in getitem(self, key)
851
852 elif key_is_scalar:
–> 853 return self._get_value(key)
854
855 if is_hashable(key):
F:\Anacondaaa\lib\site-packages\pandas\core\series.py in _get_value(self, label, takeable)
959
960 # Similar to Index.get_value, but we do not fall back to positional
–> 961 loc = self.index.get_loc(label)
962 return self.index._get_values_for_loc(self, loc, label)
963
F:\Anacondaaa\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3080 return self._engine.get_loc(casted_key)
3081 except KeyError as err:
-> 3082 raise KeyError(key) from err
3083
3084 if tolerance is not None:
KeyError: 0
Reasons and Suggestions
keyerror means no data, because np.concatenate itself is connected with the original index, and it doesn’t work because the original index is no longer continuous in the data cleaning process.
Reset the contiguous indexes or use other methods to join the list to achieve this effect.
Read More:
- [Solved] raise KeyError(key) from err KeyError: ‘Dates‘
- For the problem of rejecting old usage errors after numpy is updated, modified in numpy 1.20; for more details and guidance
- [Solved] Pytorch Tensor to numpy error: RuntimeError: Can‘t call numpy() on Tensor that requires grad.报错
- Python Pandas Error: KeyError: 0 [How to Solve]
- numpy.AxisError: axis 1 is out of bounds for array of dimension 1
- [Solved] pytorch Error: KeyError: tensor(2, device=‘cuda:0‘)
- [Solved] PyTorch Lightning Error: KeyError: ‘hidden_states‘
- Python quote error: * * * keyerror: u ‘\ uxx’ [How to Solve]
- Error in sitecustomize set PYTHONVERBOSE for traceback KeyError: ‘PYTHONPATH’
- [Solved] KeyError: ‘Transformer/encoderblock_0/MultiHeadDotProductAttention_1/query\\kernel is
- How to Solve Automatic error keyerror:***‘
- Flash cli encountered a keyerror “migrate” [How to Solve]
- odoo Error: KeyError:‘ir.http‘ [How to Solve]
- How to Fix keyerror in Python dictionary lookup
- [Solved] flash initializate database error: Keyerror: ‘migrate’
- [Solved] mnn Import Error: initMNN: init numpy failed
- [Solved] D455 Depth Camera Error: keyerror: ‘frame_ device_ t‘
- [Solved] fit function error: KeyError: ‘squared_error‘
- KeyError: b ‘TEST’ problem in python3 conversion from csn-rcnn code