Python数据分析与展示笔记

第二周plt

plt.hist问题

import numpy as np
import matplotlib.pyplot as plt

np.random.seed(0)
mu ,sigma =100,20#均值和标准差
a=np.random.normal(mu,sigma,size = 100)
plt.hist(a,20,density=True,histtype= 'stepfilled',facecolor = 'b',alpha = 0.75)#normed=1已经失效,改为density=True
plt.title('Histogram')

plt.show()

plt极坐标图

import numpy as np
import matplotlib.pyplot as plt   
  
N = 20  #表示极坐标图中数据的个数
theta = np.linspace(0.0,2*np.pi,N,endpoint=False)  #起始值0,结束值2∏,元素个数(等分角度),是否将最后结束值放入数据
radii = 10*np.random.rand(N)  #生成每个元素对应的值,一维数组含20列
width = np.pi/4*np.random.rand(N)  #∏/4*np.random..rand(N)  生成宽度值

ax = plt.subplot(111,projection="polar")  #111绘制一个绘图区域,projection给出了polar绘制极坐标图的指示
bars = ax.bar(theta,radii,width=width,bottom=0.0)  #left(绘制极坐标区域中那些颜色区域的时候是从哪开始的<角度>),height(中心点到边缘的长度),width(每个绘图区域在角度范围内辐射的面积)

for r,bar in zip(radii,bars):
    bar.set_facecolor(plt.cm.viridis(r/10.))  #使用for循环对每一个绘图区域进行颜色和透明度的设置,若是没有这个那么全是蓝色
    bar.set_alpha(0.5)
    
plt.show()

在这里插入图片描述
在这里插入图片描述
以上可能由于版本,无顺序问题

在这里插入图片描述
最近在使用DataFrame的ix方法时,出现“AttributeError: ‘DataFrame’ object has no attribute ‘ix’”报错

上网查询之后发现,在pandas的1.0.0版本开始,移除了Series.ix and DataFrame.ix 方法。

我的解决方法:使用DataFrame的loc方法或者iloc方法进行替换吧。
然后这里给出一个关于loc和iloc的区别,别人的博客说的很详细:

https://blog.csdn.net/sushangchun/article/details/83514803

索引类型的使用出现的问题
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

lu750310

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

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

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

打赏作者

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

抵扣说明:

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

余额充值