AttributeError: module 'pandas' has no attribute 'NA'
时间: 2023-09-20 10:08:40 浏览: 502
使用pandas
This error occurs when you try to use the attribute "NA" from the pandas module, but it does not exist.
The "NA" attribute was introduced in pandas version 1.0 as a replacement for the "NaN" value. If you are using an older version of pandas, you may see this error.
To fix this error, you can upgrade pandas to version 1.0 or later:
```
pip install pandas --upgrade
```
Alternatively, you can use the "NaN" value instead of "NA" if you are working with an older version of pandas:
```
import pandas as pd
import numpy as np
df = pd.DataFrame({'A': [1, 2, np.nan],
'B': ['foo', pd.NA, 'bar']})
print(df)
```
阅读全文