科学计算库
文章平均质量分 68
科学计算库:numpy、pandas、matplotlib、scikit Learn等
tz_zs
路漫漫其修远兮,吾将上下而求索
展开
-
【NumPy】 之常见运算2(np.power 幂运算)
____tz_zsnp.powerpower(x1, x2, /, out=None, *, where=True, casting=‘same_kind’, order=‘K’, dtype=None, subok=True[, signature, extobj])幂运算(指数运算),对x1中的元素进行x2中元素次幂的计算。x1 : array_like,底数x2 : array_l...原创 2019-05-14 16:18:55 · 15083 阅读 · 0 评论 -
【pandas】 排序 DataFrame.rank
____tz_zsDataFrame.rank()df.rank(self, axis=0, method=‘average’, numeric_only=None, na_option=‘keep’, ascending=True, pct=False)axis : 0 or ‘index’, 1 or ‘columns’,默认为 00 或者 ‘index’ 表示得到的是每一行的排名...原创 2019-02-28 21:01:02 · 7419 阅读 · 0 评论 -
【NumPy】 条件选取数组中的值(ndarray[ndarray>x]、np.maximum、np.maximum、np.clip)
____tz_zsndarray[ndarray>x]#!/usr/bin/python2.7# -*- coding:utf-8 -*- """@author: tz_zs"""import numpy as np n = np.array(原创 2019-02-20 21:13:57 · 2211 阅读 · 0 评论 -
【NumPy】 快速构建 ndarray 对象(np.empty、np.full、np.titl、np.r_、np.linspace)
____tz_zsnumpy 提供了多了函数来快速创建不同需求的数组。对于普通的 ndarray 的创建、切片、复制、改变维度和数据类型等操作,见我另一篇博客:https://blog.csdn.net/tz_zs/article/details/73929778emptynp.empty 构造一个长度为 shape 的未初始化数组,这个数组的元素可能是内存位置上存在的任何数值。e...原创 2019-02-19 12:08:36 · 23927 阅读 · 0 评论 -
【NumPy】 print 打印全部 np.set_printoptions
____tz_zsset_printoptionsnp.set_printoptions 设置打印选项,这些选项决定显示浮点数、数组和其他NumPy对象的方式。numpy.set_printoptions(precision=None, threshold=None, edgeitems...原创 2019-02-12 18:33:25 · 10654 阅读 · 0 评论 -
DeprecationWarning: numpy.core.umath_tests
____tz_zs/usr/local/lib/python2.7/dist-packages/sklearn/ensemble/weight_boosting.py:29: DeprecationWarning: numpy.core.umath_tests is an internal NumPy module and should not be imported. It will be...原创 2019-01-12 18:41:37 · 5120 阅读 · 0 评论 -
【numpy】 之 np.eye
____tz_zs使用 np.eye 生成对角矩阵。numpy.eyenumpy.eye(N, M=None, k=0, dtype=<class 'float'>, order='C')https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.eye.html生成一个对角线为1,其余位置为0...原创 2018-10-24 17:41:21 · 1594 阅读 · 0 评论 -
【matplotlib】 之 _tkinter.TclError: no display name and no $DISPLAY environment variable
我在远程服务器上运行matplotlib画图时报错: _tkinter.TclError: no display name and no $DISPLAY environment variable原因是服务器没有图形界面方法1: 在 from matplotlib import pylot 之前,添加代码:import matplotlib matplotlib.use(‘Agg...原创 2018-09-11 16:52:39 · 4557 阅读 · 0 评论 -
【matplotlib】 之 清理、清除 axes 和 figure (plt.cla、plt.clf、plt.close)
____tz_zsfigure 的重复利用能大大节约时间,但是 matplotlib 维护的 figure 有数量上限(RuntimeWarning: More than 20 figures have been opened.)。并且,不断的创建新的 figure 实例,很容易造成内存泄漏,而应合理的复用,能大大的提高运行速度。此外,在某些情况下,不清理 figure 将有可能造成在第一幅中...原创 2018-08-03 19:18:03 · 140655 阅读 · 3 评论 -
【matplotlib】 之 RuntimeWarning: More than 20 figures have been opened.
____tz_zs.如果你创建了太多的 figure 对象,你会收到这个警告。使用以下代码,能清除并且关闭掉 figure 对象。plt.cla()plt.close("all").但是请注意,如果你需要画很多图,这样频繁的 “创建→清除” 是会拖慢你的代码运行速度的。最好的办法是,只创建一个 figure 对象,在画下一个图之前,使用 plt.clf() 清理掉 ax...原创 2018-08-03 14:55:04 · 27486 阅读 · 3 评论 -
【matplotlib】 之 pyplot 中常用方法的源码调用过程(plt.plot、plt.scatter、plt.hist、plt.bar、plt.show、plt.savefig)
____tz_zs关于这些方法的使用见 matplotlib 模块的简单使用 ,本文是关于这些方法在源码中的调用过程,用以加深对matplotlib库的理解。 plt.plot、plt.scatter、plt.hist、plt.bar 等plt.plot、plt.scatter、plt.hist、plt.bar 等方法均调用 gcf() 获取 figure 对象,然后调用 figu...原创 2018-08-03 00:32:35 · 6748 阅读 · 0 评论 -
【pandas】 之更改行名列名 rename、重建索引 reindex
____tz_zspandas.DataFrame.rename更改行名列名。传入的函数或字典值必须是1对1的,没有包含在字典或者Series中的标签将保持原来的名称。字典中包含df中没有的标签,不会报错。pandas.DataFrame.renameDataFrame.rename(mapper=None, index=None, columns=None, axis=None,...原创 2018-08-02 12:41:43 · 28352 阅读 · 0 评论 -
【pandas】 DataFrame 对象的常用计算方法(sum、mean、max、min、idxmax、idxmin、cumsum、mad、std、var、diff、pct_change、corr)
____tz_zs参数 axisaxis=0 对每一列进行操作axis=1 对每一行进行操作参数 skipna计算中,pandas 会默认排除NaN值,设置 skipna=False 将不再排除 NaN 值.#!/usr/bin/python2.7# -*- coding:utf-8 -*-"""@author: tz_zs"""import...原创 2018-08-02 10:45:10 · 20676 阅读 · 0 评论 -
【pandas】 之画图 DataFrame.plot
____tz_zs使用 matplotlib / pylab 制作 DataFrame 数据的图。 pandas.DataFrame.plothttps://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.plot.htmlDataFrame.plot(x=None, y=None, kind='l...原创 2018-08-02 00:22:07 · 13130 阅读 · 0 评论 -
【pandas】 之 Series、DataFrame 的拼接 —— pd.concat、df.append(df)
____tz_zs官网相关介绍:https://pandas.pydata.org/pandas-docs/version/0.22/generated/pandas.concat.htmlhttps://pandas.pydata.org/pandas-docs/stable/merging.html#.#!/usr/bin/python2.7# -*- coding:u...原创 2018-07-27 18:23:24 · 49208 阅读 · 1 评论 -
【pandas】 之 df.sub、df.rsub
____tz_zspandas.DataFrame.subDataFrame.sub(other, axis='columns', level=None, fill_value=None)https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.sub.htmlpandas.DataFrame.r...原创 2018-07-23 21:31:20 · 8444 阅读 · 0 评论 -
【pandas】 之 DataFrame 保存为文件 (df.to_csv、df.to_json、df.to_html、df.to_excel)
____tz_zsDataFrame数据的保存和读取df.to_csv写入到csv文件 pd.read_csv读取csv文件 df.to_json写入到json文件 pd.read_json读取json文件 df.to_html写入到html文件 pd.read_html读取 html文件 df.to_excel 写入到 excel 文件 ...原创 2018-07-21 05:18:50 · 342934 阅读 · 10 评论 -
【matplotlib】 之 plt.figure
____tz_zs matplotlib.pyplot.figure创建一个图形(figure)对象。官网 matplotlib.pyplot.figure def figure(num=None, # autoincrement if None, else integer from 1-N figsize=None, # defaults to ...原创 2018-07-18 01:38:12 · 4399 阅读 · 0 评论 -
【matplotlib】 之 plt.subplot
____tz_zsmatplotlib.pyplot.subplot(*args, **kwargs) 返回一个指定子图分布的网格位置的 figure 对象。官网链接matplotlib.pyplot.subplot 参数:subplot(nrows, ncols, index, **kwargs)分别指定 (行数,列数,位置)其他参数:facecolor:...原创 2018-07-17 23:57:08 · 1448 阅读 · 0 评论 -
【matplotlib】 之 plt.subplots
____tz_zs matplotlib.pyplot.subplots创建一个图像对象(figure) 和 一系列的子图(subplots)。官网:https://matplotlib.org/api/_as_gen/matplotlib.pyplot.subplots.html (网页最下方有很多demo).源码 matplotlib.pyplot.subplots...原创 2018-07-16 19:51:16 · 9544 阅读 · 0 评论 -
【pandas】 之 pandas.date_range 函数
____tz_zs使用pandas.date_range 函数,能够非常方便的生成 指定频率、指定起始时间的时间序列。一、pandas.date_range 参数介绍pandas.date_range(start=None, end=None, periods=None, freq='D', tz=None, normalize=False, name=None, closed=N...原创 2018-07-04 18:27:27 · 7117 阅读 · 2 评论 -
Python 【scikit-image】
____tz_zs未完(不小心点了发布)scikit-image是图像处理算法的集合# -*- coding: utf-8 -*-"""@author: tz_zs"""from skimage.color import rgb2grayfrom skimage import ioimport matplotlib.pyplot as pltim = io.imread(...原创 2018-07-04 14:47:37 · 382 阅读 · 0 评论 -
【NumPy】 之常见运算四舍五入、取整、条件选取(np.around、np.floor、np.ceil、np.where)
____tz_zs之前把 numpy 资料写在了同一篇博客里,发现非常难以查阅,于是按功能切分开来。https://blog.csdn.net/tz_zs/article/details/73929778https://blog.csdn.net/tz_zs/article/details/80773612https://blog.csdn.net/tz_zs/articl...原创 2018-06-22 17:07:41 · 150240 阅读 · 7 评论 -
【NumPy】 之 random
____tz_zs之前把 numpy 资料写在了同一篇博客里,发现非常难以查阅,于是按功能切分开来。np.random官方文档:https://docs.scipy.org/doc/numpy/reference/routines.random.htmlnumpy 的 random 模块中文翻译文档:http://www.mamicode.com/info-detail-5076...原创 2018-06-22 15:09:44 · 290 阅读 · 0 评论 -
【NumPy】 之常见运算(min、max、mean、sum、exp、sqrt、sort、乘法、点积、对象拼接/切分)
____tz_zs之前把 numpy 资料写在了同一篇博客里,发现非常难以查阅,于是按功能切分开来。https://blog.csdn.net/tz_zs/article/details/73929778https://blog.csdn.net/tz_zs/article/details/80773612https://blog.csdn.net/tz_zs/article/d...原创 2018-06-22 15:05:21 · 16041 阅读 · 0 评论 -
【seaborn】 的使用笔记
____tz_zsseaborn库 使用笔记 风格设置·# -*- coding: utf-8 -*-"""@author: tz_zs风格设置"""import numpy as npimport matplotlib.pyplot as pltimport seaborn as snsdef sinplot(flip=1): x = np....原创 2018-05-14 11:00:48 · 1247 阅读 · 0 评论 -
【scikit-image】 图片读取、显示和保存
____tz_zsskimage提供了io模块,顾名思义,这个模块是用来图片输入输出操作的。·# -*- coding: utf-8 -*-"""@author: tz_zs图片读取、显示与保存skimage.io模块"""from skimage import io, color# skimage提供了io模块,顾名思义,这个模块是用来图片输入输出操作的。img ...原创 2018-04-02 21:53:15 · 9745 阅读 · 2 评论 -
二值图像、灰度图像、彩色图像
____tz_zs二值图像二值图像(Binary Image),按名字来理解只有两个值,0和1,0代表黑,1代表白,或者说0表示背景,而1表示前景。其保存也相对简单,每个像素只需要1Bit就可以完整存储信息。如果把每个像素看成随机变量,一共有N个像素,那么二值图有2的N次方种变化,而8位灰度图有255的N次方种变化,8为三通道RGB图像有255*255*255的N次方种变化。也就是说同样尺寸的图像...原创 2018-03-31 12:53:17 · 53640 阅读 · 8 评论 -
【scipy】 scipy.ndimage 数学形态学(Mathematical morphology)
____tz_zs笔记形态学形态学(morphology)一词通常表示生物学的一个分支,该分支主要研究动植物的形态和结构。而我们图像处理中指的形态学,往往表示的是数学形态学。数学形态学(Mathematical morphology) 是一门建立在格论和拓扑学基础之上的图像分析学科,是数学形态学图像处理的基本理论。其基本的运算包括:二值腐蚀和膨胀、二值开闭运算、骨架抽取、极限腐蚀、击中...原创 2018-03-31 04:25:03 · 2788 阅读 · 0 评论 -
【matplotlib】 模块的简单使用
____tz_zs笔记https://matplotlib.orgMatplotlib 是一个 Python 2D 绘图库,可以在各种平台上以各种硬拷贝格式和交互式环境生成出版质量数据,专为轻松生成简单而强大的可视化而量身定制。 图片读取、显示与保存·# -*- coding: utf-8 -*-"""@author: tz_zs图片读取、显示与保存使用matpl...原创 2017-11-09 16:30:17 · 899 阅读 · 0 评论 -
【pandas】 之 Series、DataFrame 创建、查询、修改
____tz_zs笔记pandas(Python Data Analysis Library) 是基于 NumPy 的一个强大的分析结构化数据的工具集,用于数据挖掘,数据分析等任务。Pandas 纳入了大量库和一些标准的数据模型,提供了高效地操作大型数据集所需的工具。pandas提供了大量能使我们快速便捷地处理数据的函数和方法。一、pandas.Seriespandas.Seri...原创 2017-11-01 14:43:04 · 1058 阅读 · 0 评论 -
Python os 和 pathlib 模块
____tz_zs笔记os文档: https://docs.python.org/3.6/library/os.htmlos 模块提供了与系统、目录操作相关的功能,不受平台的限制os.remove() 删除文件os.makedirs() 创建多层目录os.rmdir() 删除单级目录os.rename() 重命名文件os.path.isfile() 判断是否为文件os.path.isdir() 判...原创 2017-10-22 23:56:49 · 878 阅读 · 0 评论 -
【NumPy】 ndarray对象创建、切片、复制、改变维度和数据类型
____tz_zs之前把 numpy 资料写在了同一篇博客里,发现非常难以查阅,于是按功能切分开来。https://blog.csdn.net/tz_zs/article/details/73929778https://blog.csdn.net/tz_zs/article/details/80773612https://blog.csdn.net/tz_zs/article/d...原创 2017-06-30 02:59:03 · 5733 阅读 · 3 评论