数据可视化

数据可视化

例如在jupyter中运行一段这样的代代码:

import numpy as np
import pandas as pd
df1 = pd.DataFrame(data = np.random.randn(1000,4),
              index = pd.date_range(start='27/6/2012',periods=1000),
               columns = list('ABCD'))
df1

运行结果如下:
结果1


线性图:

df1.cumsum().plot()

结果如下:
结果1


柱形图:

利用bar函数:

df1.plot.bar(stacked = True) #stacked参数决定是否堆叠

饼图:表示百分比

利用pie函数:

1
2
3
4
5
df2 = pd.DataFrame(data = np.random.randn(4,2),
columns = ['one','two'],
index = list('ABCD')
)
df2.plot.pie(suplots=True,figsize=(8,8))

运行结果如下:

结果1 --- #### 散点图:用于绘制A与B的关系 利用scatter函数作图:
Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2022-2024 Yutouegg
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信