AttributeError: 'Series' object has no attribute 'reshape'
时间: 2023-09-22 16:07:01 浏览: 72
python报错: 'list' object has no attribute 'shape'的解决
5星 · 资源好评率100%
This error occurs when you try to use the reshape method on a pandas Series object. The reshape method is only available for numpy arrays and not for pandas Series.
To fix this error, you should convert the Series object to a numpy array using the values attribute and then use the reshape method on the resulting numpy array.
For example:
```
import pandas as pd
import numpy as np
# Create a pandas Series
s = pd.Series([1, 2, 3, 4, 5])
# Convert the Series to a numpy array and reshape it
arr = s.values.reshape((5, 1))
```
阅读全文