AttributeError: 'numpy.int64' object has no attribute 'startswith'
时间: 2023-08-19 07:04:35 浏览: 495
这个错误是因为在代码中使用了`startswith`方法,但是该方法只能用于字符串类型的数据,而不适用于`numpy.int64`类型的数据。在引用中提到了解决这个问题的方法。可以将要遍历的列的数据类型转换为字符串类型。在这种情况下,可以使用`astype(str)`方法将`patient`列的数据类型转换为字符串类型。修改后的代码如下:
```
def charlson(day):
patient = patient = 2
```
这样修改后,应该就能解决`AttributeError: 'numpy.int64' object has no attribute 'startswith'`的问题了。引用中提到了这个解决方法。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* *3* ['numpy.int64' object has no attribute 'startswith'解决办法](https://blog.csdn.net/youruolinmc/article/details/79066170)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
- *2* [import obspy报错‘numpy.int64‘ object has no attribute ‘split‘`](https://blog.csdn.net/weixin_44001547/article/details/122727400)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文