axis

数据分析day03

守給你的承諾、 提交于 2020-01-25 17:57:13
数据分析day03 4.基于pandas的数据清洗 处理丢失数据 有两种丢失数据: None np.nan(NaN) In [1]: import numpy as np import pandas as pd from pandas import Series,DataFrame import tushare as ts#财经数据接口包 import matplotlib.pyplot as plt 两种丢失数据的区别 In [2]: type(np.nan) Out[2]: float In [5]: np.nan + 3 Out[5]: nan In [3]: type(None) Out[3]: NoneType pandas中的None和NAN In [10]: df = DataFrame(data=np.random.randint(0,100,size=(8,5))) df Out[10]: 0 1 2 3 4 0 44 91 92 51 55 1 23 22 92 35 83 2 21 52 40 63 29 3 94 51 24 70 59 4 27 78 1 21 17 5 94 57 5 43 22 6 87 31 58 30 82 7 93 28 54 7 93 In [12]: df.iloc[1,2] = None df.iloc[3,4] =

NumPy 8 - 数组操作

限于喜欢 提交于 2020-01-25 13:04:54
NumPy 8 - 数组操作 文章目录 NumPy 8 - 数组操作 一、修改数组形状 所有函数方法 1、numpy.reshape 修改形状 实例 2、numpy.ndarray.flat 迭代器 3、numpy.ndarray.flatten 数组拷贝 4、numpy.ravel 展平 二、翻转数组 1、numpy.transpose numpy.ndarray.T 2、numpy.rollaxis 3、numpy.swapaxes 交换数组的两个轴 三、修改数组维度 1、numpy.broadcast 2、numpy.broadcast_to 广播到新形状 3、numpy.expand_dims 插入拓展 4、numpy.squeeze 四、连接数组 1、numpy.concatenate 沿指定轴连接 2、numpy.stack 沿新轴连接 3、numpy.hstack 水平堆叠 4、numpy.vstack 垂直堆叠 五、分割数组 1、numpy.split 2、numpy.hsplit 水平分割数组 3、numpy.vsplit 沿着垂直轴分割 六、数组元素的添加与删除 1、numpy.resize 2、numpy.append 3、numpy.insert 4、numpy.delete 5、numpy.unique 转载编辑自: https://www.runoob

Python与数据(一)——数据分析Pandas

被刻印的时光 ゝ 提交于 2020-01-25 03:20:07
Pandas 什么是Pandas 数据结构 Series DataFrame 获取数据源 导入文件 查看数据表的大小 查看数据类型 查看数值分布情况 数据预处理 判断哪个是NAN 删除缺失值 填充缺失值 删除重复值 数据类型转换 设置索引 数据选择 选择列 选择行 筛选行 行列同时选择 loc方法 iloc方法 布尔索引+普通索引 连续的行列 单个行/列+连续列/行 数值操作 数值替换 数值排序 数值排名 数值删除 删除列 删除行 数值计算 计数 获取唯一值 数值查找 区间切分 插入列 行列互换 层次化索引 数据运算 加减乘除 比较 计数 求和 求均值 求最大、最小值 求中位数 求众数 求方差 求标准差 指定列、行运算 数据分组 aggregate方法 reset_index方法 表拼接 横向拼接 左连接 右连接 外连接 重复列 纵向拼接 数据导出 Python数据分析系列以《对比Excel,轻松学习Python数据分析》为参考进行学习 什么是Pandas Pandas是基于Numpy的一种工具,主要用于处理数据进行分析,它纳入了大量的库和一些标准的数据模型,提供了操作大型数据集所需的工具 数据结构 根据百度百科,Pandas里的数据结构有以下几种 Series:一维数组,与Numpy中的一维array类似。二者与Python基本的数据结构List也很相近

Numpy中numpy.concatenate()函数、numpy.delete()函数、numpy.mean()函数参数axis=0与axis=1的区分

余生长醉 提交于 2020-01-24 05:09:19
Numpy中函数参数axis=0与axis=1的区分 1.问题描述 在使用Numpy中某些函数时,可能会遇到aixs=0与aixs=1的理解困惑。例如: 对于函数1 : 数组拼接函数numpy.concatenate((a1,a2,…), axis=0),其中ai为数组类型 1)当参数为一维数组时 下面代码 import numpy as np a1 = np . array ( [ 1 , 2 , 3 ] ) a2 = np . array ( [ 4 , 5 , 6 ] ) a3 = np . array ( [ 7 , 8 , 9 ] ) print ( np . concatenate ( ( a1 , a2 , a3 ) , axis = 0 ) ) print ( np . concatenate ( ( a1 , a2 , a3 ) , axis = 1 ) ) 结果为: 只能在aixs=0方向拼接,且结果仍然为一维数组。 2)当参数为二维数组时 下面代码 import numpy as np a1 = np . array ( [ [ 1 , 2 , 3 ] , [ 3 , 2 , 1 ] ] ) a2 = np . array ( [ [ 4 , 5 , 6 ] , [ 6 , 5 , 4 ] ] ) a3 = np . array ( [ [ 7 , 8 , 9

数据挖掘一般流程及模型整理

断了今生、忘了曾经 提交于 2020-01-23 00:04:50
一.数据读取: csv文件:csv_data= pd.read_csv(’/路径/test.csv’) txt文件:f= open(’/路径/test.txt’, ‘r’) excel文件: import xlrd f=xlrd.open_workbook(r'\路径\demo.xlsx',formatting_info=True) table =data.sheet_by_name("Sheet2") or df = pd.read_excel("\路径\window regulator.xlsx",sheetname="Sheet2") 二.数据处理和清洗: 数据清洗: A.调整数值及格式,去掉噪声,不可信值,缺失值较多的字段 1)去掉空格,换行符: " xyz ".strip() # returns “xyz” " xyz ".lstrip() # returns "xyz " " xyz “.rstrip() # returns " xyz” " x y z ".replace(’ ', ‘’) # returns “xyz” 2)用split断开再合上 ‘’.join(your_str.split()) 3)用正则表达式来完毕替换: import re strinfo = re.compile(‘word’) b = strinfo.sub(‘python’,a

tensorflow数据统计

拜拜、爱过 提交于 2020-01-22 22:19:48
本篇内容包括,tf.norm(张量的范数)、tf.reduce_min/max(最大最小值)、tf.argmax/argmin(最大最小值的位置)、tf.equal(张量的比较)、tf.unique(张量的独特值) 1.tf.norm   · 二范数 ||x|| 2 = (Σx k 2 ) 1/2   · 一范数 ||x|| 1 = Σ|x k |   · 无穷范数 ||x|| ∞ = max|x k | # 二范数 a = tf.ones([2,2]) print(tf.norm(a)) print(tf.norm(a,ord=2,axis=0)) print(tf.sqrt(tf.reduce_sum(tf.square(a)))) # 一范数 print(tf.norm(a,ord=1)) print(tf.norm(a,ord=1,axis=0)) print(tf.norm(a,ord=1,axis=1)) 2.reduce_min/max/mean a = tf.random.normal([4,10]) # 全值,即把tensor打平为[40] print(tf.reduce_min(a),tf.reduce_max(a),tf.reduce_mean(a)) # 指定参数轴 print(tf.reduce_min(a,axis=1),tf.reduce_max(a

Java Web Services - Is Axis Necessary?

笑着哭i 提交于 2020-01-22 20:11:08
问题 Is AXIS or CXF necessary for Java web services? Can it be all done via the JDK (1.6)? 回答1: Is AXIS or CXF necessary for Java web services? No. Although Axis2 is the most popular framework to work with Web Services is not the only way to do them. Can it be all done via the JDK (1.6)? Yes, but it is way much harder. You will benefit tremendously from using a framework used by others apps and from the bug fixes the development team provide. Doing all by hand is like reinventing the wheel. If you

Java Web Services - Is Axis Necessary?

梦想的初衷 提交于 2020-01-22 20:10:40
问题 Is AXIS or CXF necessary for Java web services? Can it be all done via the JDK (1.6)? 回答1: Is AXIS or CXF necessary for Java web services? No. Although Axis2 is the most popular framework to work with Web Services is not the only way to do them. Can it be all done via the JDK (1.6)? Yes, but it is way much harder. You will benefit tremendously from using a framework used by others apps and from the bug fixes the development team provide. Doing all by hand is like reinventing the wheel. If you

【数据分析与科学计算可视化】numpy 和 matplotlib库总结

让人想犯罪 __ 提交于 2020-01-21 14:01:51
一、numpy库 numpy:科学计算包,支持N维数组运算、处理大型矩阵、成熟的广播函数库、矢量运算、线性代数、傅里叶变换、随机数生成,并可与C++/Fortran语言无缝结合。树莓派Python v3默认安装已经包含了numpy。 另: scipy:scipy依赖于numpy,提供了更多的数学工具,包括矩阵运算、线性方程组求解、积分、优化、插值、信号处理、图像处理、统计等等。 1.扩展库numpy简介 导入模板:(交换式) >>>import numpy as np 2.numpy库应用于数组 (1)简单数组的生成 >>>import numpy as np #把列表转化为数组 >>> np.array([0,1,2,3,4]) array([0, 1, 2, 3, 4])>>>np.array((0,1,2,3,4)) # 元组转化为数组array([0, 1, 2, 3, 4]) >>>np.array(range(5)) # 把range对象转换成数组 array([0, 1, 2, 3, 4]) >>>np.array([[1,2,3,4,],[5,6,7,8]]) #二维数组 array([[1, 2, 3, 4], [5, 6, 7, 8]]) >>>np.arange(8) # 类似于内置函数range() array([0,1,2,3,4,5,6,7]) >>

PyQt5 QtChart自定义轴代码顺序

跟風遠走 提交于 2020-01-21 04:05:24
使用PyQt5的QtChart作图时,出现的问题记录一下,以便查阅与遇到坑的人爬出,版本为PyQt5.10 当自定义轴时,会出现轴与数据点不统一,不对齐的问题,虽然有关联轴的方法,但代码顺序仍需很小心,谁叫Python是解释型语言呢。 注意代码中的 一定!!! ,最后有总结。 font = QFont ( ) font . setPointSize ( 7 ) # 1 自定义时间类型的X轴 axis_X = QDateTimeAxis ( ) axis_X . setRange ( min_x , max_x ) # 设置范围 axis_X . setFormat ( 'yyyy-MM-dd' ) # 显示的格式 axis_X . setLabelsAngle ( - 90 ) # 设置标签旋转的角度 axis_X . setTickCount ( tick_count ) # 设置刻度个数 axis_X . setLabelsFont ( font ) # 设置字体大小等 axis_X . setGridLineVisible ( False ) # 设置网格纵向线不可见 """ 一定!!!要在添加图线前将轴加入图表对象中 """ chart . addAxis ( axis_X , Qt . AlignBottom ) # 加入坐标x轴 # 2 自定义数值型的Y轴(左侧)