axis

科学计算库Numpy基础操作

社会主义新天地 提交于 2020-02-27 03:22:17
pycharm,python3.7,numpy版本1.15.1 2018年9月11日04:23:06 """ 科学计算库Numpy基础操作 时间:2018\9\11 0011 """ import numpy print("""\n------以矩阵的方式读取数据------\n ------------genfromtxt函数('文件路径',delimiter = '分隔符',dtype = 读取方式)---------------------""") """ numpy.ndarray可以当做一个矩阵 """ np_test = numpy.genfromtxt('Numpy_test.txt', delimiter = ',', dtype = str) # 通常以str方式读取,如果有float,再进行转换 print(type(np_test)) print(np_test) # print(help(numpy.genfromtxt)) # 打印帮助文档 print("""\n------numpy.array------\n ------------numpy中最核心的结构------------------------------------------""") # 传入list结构,转换为ndarray格式 vector = numpy.array([5, 10,

python中axis=0和axis=1的问题记录

老子叫甜甜 提交于 2020-02-27 01:35:01
之前一直搞不清axis = 0 和 axis = 1 之间的区别,一会是按行求和,一会是按列遍历,那到底axis是咋操作的呢?查找了些资料,发现了一种很好的解释就是: 0轴垂直往下,1轴向右水平延伸。 啥意思?? 尝试一下好了 import numpy as np import pandas as pd tmp = np . random . randint ( 1 , 10 , 12 ) . reshape ( 3 , 4 ) tmp #1到10随机生成12个整数,并重组成3行4列的数组 array ( [ [ 5 , 6 , 4 , 4 ] , [ 2 , 7 , 2 , 9 ] , [ 2 , 4 , 1 , 9 ] ] ) tmp . sum ( axis = 1 ) #这里可以看出来,其实就是把每行加总了,axis = 1时向右水平延伸计算 array ( [ 19 , 20 , 16 ] ) tmp . max ( axis = 1 ) #同样的,axis = 1时,水平方向寻找最大的值 array ( [ 6 , 9 , 9 ] ) np . insert ( tmp , 1 , 0 , axis = 1 ) #同样还是按照水平方向插入值,即第二列插入一个全零的值 array ( [ [ 5 , 0 , 6 , 4 , 4 ] , [ 2 , 0 , 7 , 2 ,

Pandas

家住魔仙堡 提交于 2020-02-26 13:35:56
Pandas简介 Pandas 是python的一个数据分析包,pandas是一款数据处理工具,集成了numpy以及matplotlib,拥有便捷的数据处理以及文件读取能力 Pandas 提供了三种数据对象,分别是 Series、 DataFrame 和 Panel。 其中 , Series 用于保存 一维类的数据, DataFrame 用于保存二维类的数据, Panel 用于保存三维类或者可变维度的数据。 在通常的数据分析中,我们经常使用 Series 和 DataFrame 这两种类型的数据,所以这两种类型 要重点介绍。 数据结构 Series:一维数组,与Numpy中的一维array类似。二者与Python基本的数据结构List也很相近,其区别是:List中的元素可以是不同的数据类型,而Array和Series中则只允许存储相同的数据类型,这样可以更有效的使用内存,提高运算效率。 Time- Series:以时间为索引的Series。 DataFrame:DataFrame是⼀个二维的表格型数据结构,它含有⼀组有序的列,每列可以是不同的值类型(数值、字符串、布尔值等)。DataFrame既有⾏索引也有列索引,它可以被看做由Series组成的字典(共⽤同⼀个索引)。DataFrame中的数据是以⼀个或多个⼆维块存放的(⽽不是列表、字典或别的⼀维数据结构)。 Panel

Highcharts time X axis

筅森魡賤 提交于 2020-02-25 13:22:45
问题 I would like to ask if somebody knows how to set X axis in Highcharts to time. My aplication is taking data from database and the frequency of the samples is 250ms. I want the X axis not to show counted values but something like time. I render 2500 values at once so that means 10 secs. The best would be to have on X axis and a mark there every 0.5 sec that means every 125 samples a mark. Like (0 samples = 0 sec);(125 samples = 0,5 sec);(500 samples = 1 sec);(725 samples = 1.5 sec) Thank you

基于D3.js 绘制一个折柱混合图

三世轮回 提交于 2020-02-25 02:14:37
测试题目:使用 D3 绘制一个折柱混合图,示例数据如下: data = [   ["时间", "销售额", "增长率(%)"],   ["一月", 27506, 20.8],     ["二月", 24399, 5.4],   ["三月", 23120, 22],   ["四月", 22053, 0.4],   ["五月", 21221, 3.1],   ["六月", 22848, 8.6],   ["七月", 20178, 28.7],   ["八月", 16927, 5.5],   ["九月", 19808, 13.5],   ["十月", 22450, 3.7] ]; 绘制要求:   (1) 需要建立完整的坐标系及网格线;   (2) 第二列为柱图数据,第三列为折线图数据;   (3) 将柱图数值文本标识在柱形上方。 HTML代码: 1 <html> 2 <head> 3 4 <title> 柱形折线图</title> 5 <style> 6 7 8 .axis path, 9 .axis line{ 10 fill:none; 11 stroke:black; 12 shape-rendering:crispEdges; 13 } 14 .axis text { 15 font-family:sans-serif; 16 font-size :11px; 17 } 18

pandas api总结

一笑奈何 提交于 2020-02-24 14:02:18
基础部分:创建,简单提取,简单分析 1.创建表格 import pandas as pd import numpy as np import matplotlib . pyplot as plt s = pd . Series ( [ 1 , 3 , 5 , np . nan , 6 , 8 ] ) #创建series数组,默认创建整数索引 dates = pd . date_range ( '20140201' , periods = 6 ) #创建时间索引,开始为2014 02 01 ,持续6次 data = pd . DataFrame ( np . random . rand ( 6 , 4 ) , index = dates , columns = list ( 'ABCD' ) ) #创建DataFrame 注:最终表格格式 2.按要求提取表格信息 type = data . dtypes #返回每行的格式 head3 = data . head ( 3 ) #打印前三行、 tail5 = data . tail ( 5 ) #打印后5行 index = data . index #返回行名称‘ columns = data . columns #返回列名称 valuse = data . values #返回所有数据 3 对数据进行排序及转置处理 dataT =

NVD3.js multichart with fixed x- and y-axis

一世执手 提交于 2020-02-24 09:07:33
问题 I´m using a NVD3.js multichart to display various data. Is it possible set a fixed range for the x- and y-axis. I´ve made a Plunker example: http://plnkr.co/edit/OLN87eIE21tImHktYIH6?p=preview var chart = nv.models.multiChart() .margin({top: 30, right: 60, bottom: 50, left: 70}) .color(d3.scale.category10().range()); chart.xAxis.tickFormat(function(d) { return d3.time.format('%H:%m')(new Date(d)); }); chart.yAxis1.tickFormat(d3.format(',.1f')); chart.yAxis2.tickFormat(d3.format(',.1f')); d3

NVD3.js multichart with fixed x- and y-axis

痴心易碎 提交于 2020-02-24 09:04:02
问题 I´m using a NVD3.js multichart to display various data. Is it possible set a fixed range for the x- and y-axis. I´ve made a Plunker example: http://plnkr.co/edit/OLN87eIE21tImHktYIH6?p=preview var chart = nv.models.multiChart() .margin({top: 30, right: 60, bottom: 50, left: 70}) .color(d3.scale.category10().range()); chart.xAxis.tickFormat(function(d) { return d3.time.format('%H:%m')(new Date(d)); }); chart.yAxis1.tickFormat(d3.format(',.1f')); chart.yAxis2.tickFormat(d3.format(',.1f')); d3

计算机视觉——图像处理基础

风格不统一 提交于 2020-02-24 08:05:27
目录 1. PIL-Python图像库 1.1 图像灰度处理 代码实现 运行结果 1.2 调整尺寸及旋转 代码实现 运行结果 2. Matplotlib库 2.1 画图、描点和线 代码实现 运行结果 2.2 图像轮廓和直方图 代码实现 运行结果 3. NumPy库 3.1 灰度变换 代码实现 运行结果 3.2 直方图均衡化 代码实现 运行结果 4. SciPy模块 4.1 高斯模糊 代码实现 运行结果 1. PIL-Python图像库 1.1 图像灰度处理 代码实现 # -*- coding: utf-8 -*- from PIL import Image from pylab import * # 添加中文字体支持 from matplotlib.font_manager import FontProperties font = FontProperties(fname=r"c:\windows\fonts\SimSun.ttc", size=14) figure() pil_im = Image.open('D:\\python\pcv_data\data\empire.jpg') gray() subplot(121) title(u'原图',fontproperties=font) axis('off') imshow(pil_im) pil_im = Image.open

python — 图像处理基础

喜你入骨 提交于 2020-02-23 14:03:57
文章目录 一、图像轮廓与直方图 1. 图像轮廓 2. 直方图 3. 代码实现 二、高斯滤波 1. 高斯滤波 2. 代码实现 三、直方图均衡化 1.直方图均衡化 2. 代码实现 四、图像差分 五、图像模糊 总结: 环境:anaconda3,spyder。 一、图像轮廓与直方图 1. 图像轮廓 绘制图像的轮廓在工作中十分有用。因为绘制轮廓需要对每个坐标的像素值施加一个阈值,所以首先需要将图像灰度化。 2. 直方图 用来表征该图像像素值得分布情况。用一定的小区间来指定表征像素值的范围,每个小区间会得到落入该小区间表示范围的像素数目。 hist()函数只接受一维数组作为输入,因此在绘制图像直方图前,必须对图像进行压平处理。 3. 代码实现 实验结果: 代码: # -*- coding: utf-8 -*- from PIL import Image from pylab import * # 添加中文字体支持 from matplotlib.font_manager import FontProperties font = FontProperties(fname=r"c:\windows\fonts\SimSun.ttc", size=14) im = array(Image.open('c:\house.jpg').convert('L')) # 打开图像,并转成灰度图像 figure