Python经验总结-图形化显示(一)

写在前面
  • 积累工作中常用,但费时的数据处理技巧。
  • 利用碎片化时间完成小记。

P1: Pandas Series非科学计数法显示
pd.set_option('display.float_format', lambda x : '%.5f' % x)
data_test.sample(3)

P2: plt.title/labels 引用中文
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties


plt.figure(figsize=(6,6))
labels = '一般风险群', '低风险群', '极高风险群', '次高风险群','高风险群'
randoms = [23,7,13,51,9]
explode = [0, 0, 0.05, 0,0.1]
patches,texts,autotexts=plt.pie(x=randoms, labels=labels, explode=explode,autopct='%3.1f %%', labeldistance=1.1, startangle = 90,pctdistance = 0.6)
plt.title(u"企业破产风险占比",y = 1.1,fontsize = 12)

plt.show()

P3: Pandas 数据堆叠化显示
import matplotlib.pyplot as plt

plt.figure(figsize=(12,4))
plt.title("Series数据堆叠化显示示例",FontProperties=font,fontsize = 18)
plt.bar(stacked_df.index.tolist(),stacked_df.sort_index(ascending=True,axis=0).apple.tolist())
plt.bar(stacked_df.index.tolist(),stacked_df.sort_index(ascending=True,axis=0).apple.tolist(),bottom=stacked_df.sort_index(ascending=True,axis=0).apple.tolist())
plt.grid()
plt.xlabel('下标',FontProperties=font,fontsize = 12)
plt.ylabel('数据量',FontProperties=font,fontsize = 12)
plt.show()

最后
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xsimah

创作不易,感谢客官的打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值