KeyError: 'num' Empty DataFrame Columns: [num, ratio] Index: [] *********counts2************ Series([], Name: count, dtype: int64)
时间: 2023-12-18 20:29:46 浏览: 135
20240828-111008 python 应用题 MOOC大学名单
以下是两种解决方法:
1. 解决AttributeError: ‘DataFrame’ object has no attribute ‘score’的错误
```python
import pandas as pd
data = pd.read_excel(r"C:\Users\ASUS\Desktop\0012\data7.1.2.xlsx")
data['score'].describe()
```
2. 解决KeyError: 'num' Empty DataFrame Columns: [num, ratio] Index: [] *********counts2************ Series([], Name: count, dtype: int64)的问题
```python
# 添加参数result_type='broadcast'
datas = df.apply(func, axis=1, result_type='broadcast')
```
阅读全文