python常见命令整理

pandas中关于DataFrame行,列显示不完全(省略)的解决办法

#显示所有列
pd.set_option(‘display.max_columns’, None)
#显示所有行
pd.set_option(‘display.max_rows’, None)
#设置value的显示长度为100,默认为50
pd.set_option(‘max_colwidth’,100)

import matplotlib.pyplot as plt

# 设置中文字体和负号正常显示
matplotlib.rcParams['font.sans-serif'] = ['SimHei']
matplotlib.rcParams['axes.unicode_minus'] = False

d1 = pd.read_excel(r'D:\个人资料\直方图.xlsx')

label_list = list(d1['供应商'].values)  # 横坐标刻度显示值
num_list1 = list(d1['基金id'].values)  # 纵坐标值1
#num_list2 = [15, 30, 40, 20]  # 纵坐标值2
x = range(len(num_list1))

# 绘制条形图
rects1 = plt.bar(x, height=num_list1, color='red', label='供应商')
#rects2 = plt.bar([i+0.4 for i in x], height=num_list2, width=0.4, color='green', label='部门二')

# 设置y轴属性
#plt.ylim(0, 50)
plt.ylabel('基金数量')

# 设置x轴属性
plt.xticks([index+0.2 for index in x], label_list)
plt.xlabel("年份")
plt.title('基金管理公司的基金数量')
plt.legend()

# 显示文本
for rect in rects1:
    height = rect.get_height()
    plt.text(rect.get_x() + rect.get_width() / 2, height + 1, str(height), ha='center', va='bottom')
#for rect in rects2:
#    height = rect.get_height()
#    plt.text(rect.get_x() + rect.get_width() / 2, height + 1, str(height), ha='center', va='bottom')

plt.show()


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

立军touyo

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值