python - 如何创建趋势线日期与数据(百分比值)
问题描述
导入excel后我有数据框
Date Inflation Rate
1-Jan 0.26
2-Jan 0.3
3-Jan 0.29
4-Jan 0.29
5-Jan 0.29
6-Jan 0.29
7-Jan 0.28
8-Jan 0.28
9-Jan 0.28
10-Jan 0.27
11-Jan 0.28
12-Jan 0.28
13-Jan 0.27
14-Jan 0.28
15-Jan 0.27
16-Jan 0.27
17-Jan 0.27
18-Jan 0.27
19-Jan 0.24
20-Jan 0.26
21-Jan 0.26
22-Jan 0.26
23-Jan 0.26
24-Jan 0.25
25-Jan 0.24
26-Jan 0.22
27-Jan 0.21
28-Jan 0.19
29-Jan 0.18
30-Jan 0.19
--
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.dates as mdates
df1=pd.read_excel("PAN Country.xls")
df1.plot(x='Date',y='Inflation',title="countryinflation",marker='.',markersize=6,lw=1, color="Red",label='Inflation',legend=True,figsize=(15,7),grid=True,linestyle=':',alpha=1,stacked=True)
plt.ylabel('Inflation (%)',fontsize=15)
plt.xlabel('Plot duration',fontsize=15)
plt.ylim(0, 0.35)
plt.gca().xaxis.set_major_locator(mdates.DayLocator(8))
plt.show()
如何在此数据上创建线性趋势线。请帮助我是新手
解决方案
推荐阅读
- rest - RESTful API 设计:检索类别中的项目数
- flutter - 在最近的应用程序视图中如何处理窗口可见性
- mysql - 如何在云构建中安装 mysql 并运行脚本?
- postgresql - PostgreSQL 查询不使用索引
- javascript - 在 Map 和 navigator.geolocation 上使用 Leaflet 的多个事件
- python - 让 Livereload + Flask 触发硬刷新
- python - 如何创建强化学习神经网络来玩飞扬的小鸟?
- javascript - 为什么在 Chrome 扩展程序中请求时出现 CORB 问题?
- jquery - 无法在 select2 中读取 null 的属性“concat”
- java - 按下微调器下拉菜单时,禁用全屏模式