python
无聊的六婆
这个作者很懒,什么都没留下…
展开
-
python 从数组中随机选择一部分取出,并从原数组中删除取出的内容
可以使用numpy中的random.choice函数随机选择数组的下标numpy.random.choice(a, size=None, replace=True, p=None)#a为一维数组或int值,为一维数组时会从该数组中随机选择元素,为int值时会先生成一个np.arange(a)的数组,然后从中随机选择元素#size为int值,为选择元素的个数#replace默认为Tru...原创 2018-09-15 18:22:56 · 30343 阅读 · 1 评论 -
python 获取等间隔的数组
可以使用numpy中的linspace函数np.linspace(start, stop, num, endpoint, retstep, dtype)#start和stop为起始和终止位置,均为标量#num为包括start和stop的间隔点总数,默认为50#endpoint为bool值,为False时将会去掉最后一个点计算间隔#restep为bool值,为True时会同时返回数据...原创 2018-09-07 15:25:23 · 30115 阅读 · 1 评论 -
python matplotlib作图细节
作图存在汉字无法显示在作图代码前添加如下代码plt.rcParams['font.sans-serif'] = ['SimHei']plt.rcParams['axes.unicode_minus'] = False作图的曲线粗细调整plt.plot()中有一个参数 ‘linewidth’,修改参数可以改变曲线粗细程度一个坐标系中存在多个曲线,给曲线命名plt.plot()中有一个...原创 2019-01-17 14:42:11 · 376 阅读 · 0 评论 -
python pandas使用记录
1. 获取dataframe结构中某一部分数据在使用numpy中array格式的矩阵时,我们通常使用如A[2:4,5:10]获取数组中一部分数据,但是dataframe结构的数组就不能这么写,可以使用 iloc 方法,即index locate,另外有个相似的方法 loc , 这个方法是通过column名字进行数据定位的import pandas as pdimport numpy as n...原创 2019-02-19 21:08:09 · 405 阅读 · 0 评论