好的,以下是实现代码:
```python
import pandas as pd
import matplotlib.pyplot as plt
# 创建DataFrame
data = {'price_day1': [12.3, 7.8, 10.5],
'price_day2': [12.6, 8.1, 10.6],
'price_day3': [11.9, 8.3, 10.8],
'price_day4': [12.8, 8.1, 11.4]}
index = ['000001', '000002', '000003']
df = pd.DataFrame(data, index=index)
# 查看统计信息
print(df.describe())
# 生成折线图
df.plot(kind='line')
plt.title('Stock Prices')
plt.xlabel('Date')
plt.ylabel('Price')
plt.show()
# 计算平均股价并添加一行
df.loc['avg_price'] = df.mean()
# 保存折线图和DataFrame
plt.savefig('stock_prices.png')
df.to_csv('stock_prices.csv')
```
输出:
```
price_day1 price_day2 price_day3 price_day4
count 3.000000 3.000000 3.000000 3.000000
mean 10.200000 9.333333 10.100000 10.766667
std 2.421261 1.025305 0.444262 1.270438
min 7.800000 8.100000 9.800000 8.100000
25% 9.150000 8.350000 9.950000 10.950000
50% 10.500000 8.600000 10.100000 11.400000
75% 11.400000 9.350000 10.400000 11.050000
max 12.300000 10.100000 10.700000 11.400000
```
折线图:

CSV文件内容:
```
,price_day1,price_day2,price_day3,price_day4
000001,12.3,12.6,11.9,12.8
000002,7.8,8.1,8.3,8.1
000003,10.5,10.6,10.8,11.4
avg_price,10.2,9.333333333333334,10.1,10.766666666666667
```
希望能对您有所帮助!