'DataFrame' object has no attribute 'ix'
时间: 2023-09-09 14:13:01 浏览: 155
Python3下错误AttributeError: ‘dict’ object has no attribute’iteritems‘的分析与解决
5星 · 资源好评率100%
In recent versions of pandas, the `.ix` indexer has been deprecated and removed.
Instead, you can use `.loc` or `.iloc` indexer to access the elements of a DataFrame.
`.loc` is a label-based indexer, which means you can access the elements based on their index label. For example:
```python
df.loc[0, 'column_name']
```
`.iloc` is an integer-based indexer, which means you can access the elements based on their integer position. For example:
```python
df.iloc[0, 1]
```
If you are trying to access a specific row or column in a DataFrame, you can use `.loc` or `.iloc` with a colon to select all rows or columns. For example:
```python
df.loc[:, 'column_name']
df.iloc[:, 1]
```
阅读全文