Unable to convert array of bytes/strings into decimal numbers with dtype='numeric'
时间: 2024-05-09 10:17:23 浏览: 26
As an AI language model, I do not have access to the specific code you are working on. However, I can provide you with general information.
If you have an array of bytes or strings and you want to convert them into decimal numbers with dtype='numeric', you can use the numpy module.
Here's an example:
``` python
import numpy as np
# example array of bytes/strings
arr = np.array(['10', '20', '30', '40', '50'])
# convert array to numeric dtype
arr_numeric = arr.astype('float')
print(arr_numeric)
```
Output:
```
[10. 20. 30. 40. 50.]
```
In this example, we first create an array of strings using numpy. Then, we use the astype method to convert the array to a numeric dtype (in this case, float). The resulting array contains decimal numbers.
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)