axis

pandas操作excel操作-19-常用数据操作

怎甘沉沦 提交于 2020-03-01 23:45:02
常用数据操作 students01 = pd.read_excel('C:/students.xlsx', index_col='ID', sheet_name='page01') students02 = pd.read_excel('C:/students.xlsx', index_col='ID', sheet_name='page02') # 合并两个数据集 # 默认axis=0 表示从上到下方向 # axis = 1 表示从左到右方向 students1 = pd.concat([students01, students02], axis=0).reset_index(drop=True) students2 = pd.concat([students01, students02], axis=1) # 追加列 students1['Age'] = 25 students1['Age'] = np.repeat(25, len(students1)) # 删除列 students1.drop(columns=['Age', 'Score'], inplace=True) # 在原有的两列之间 插入新列 students1.insert(1, column='Foo', value=np.arrange(0, len(students1))) # 修改列名

np.cumsum()的用法

↘锁芯ラ 提交于 2020-03-01 19:11:53
np.cumsum(a, axis = 0)用于将数组按行累加,譬如 import numpy as np a = np . array ( [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] ] ) b = np . cumsum ( a , axis = 0 ) print ( b ) 输出结果为 [[1 2 3] [5 7 9]] Process finished with exit code 0 np.cummsum(a, axis = 1)用于将数组按列累加,譬如 import numpy as np a = np . array ( [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] ] ) b = np . cumsum ( a , axis = 1 ) print ( b ) 输出结果为 [[ 1 3 6] [ 4 9 15]] Process finished with exit code 0 来源: CSDN 作者: cyj5201314 链接: https://blog.csdn.net/cyj5201314/article/details/104595351

成功解决return tf.nn.softmax(x, axis=axis) TypeError: softmax() got an unexpected keyword argument 'axis

試著忘記壹切 提交于 2020-03-01 11:07:54
成功解决return tf.nn.softmax(x, axis=axis) TypeError: softmax() got an unexpected keyword argument 'axis 解决问题 return tf.nn.softmax(x, axis=axis) TypeError: softmax() got an unexpected keyword argument 'axis' 解决方法 修改keras得源文件 来源: CSDN 作者: 一个处女座的程序猿 链接: https://blog.csdn.net/qq_41185868/article/details/80897048

numpy中axis——轴之个人看法

人走茶凉 提交于 2020-03-01 07:43:43
最近用到numpy中sum函数,需要对不同维度进行求和,也就是指定axis参数。 环境: python3.6 + ipython 1. 初始化数组x。 In [1]: import numpy as np In [2]: x = np.array(range(24)) In [3]: x Out[3]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) 2.将x变形,并求和。(采用默认axis,将数组展为一维进行求和) In [10]: y = x.reshape(4,6) In [11]: y Out[11]: array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]]) In [12]: np.sum(y) Out[12]: 276 3. 此时我们已知轴的个数为2,也就是秩为2。分别用axis=0,axis=1尝试np.sum() In [21]: np.sum(y, axis=0) Out[21]: array([36, 40, 44, 48, 52, 56]) In [22]: np.sum

javaWEB 之 消息中间件 之 webservice 之 axis2 的使用

戏子无情 提交于 2020-03-01 04:03:24
webservice 之 axis2 的使用 简单说下如何使用webservice . webservice有个服务端,像数据库,svn,activemq,zookeeper,这些都有服务端。 服务端能做什么:服务端提供一些自定义的函数接口供客户端调用,这些接口做了什么事,怎么做的,客户端不知道,client只需调用即可,该传参数就传参数,最后可以得到返回结果 axis2 的使用 结合eclipse axis2-code-genarator axis2-service-archer 网上很多如何安装和部署的我就不多说了 如何实现的 1:axis2服务端,先编写service-写自己的函数和方法--打包成aar包,放在下载好的axis2-war包里,就可以运行该服务了。 2:客户端,根据服务端的地址生成了相应的java文件,在客户端实现步骤一般为: a: 与服务端创建连接 b:找到对应的方法类(类名与方法一样大,除了类名首字母大写外),实例化该对象,然后通过该对象set参数值,参数值是方法类的属性 c:得到该方法Response类的实例对象,是通过服务对象stub加方法函数以及参数得到的 d:最后通过response的对象的get_return()方法得到返回值 来源: oschina 链接: https://my.oschina.net/u/1444819/blog/733362

pandas操作excel-15-数据校验

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-29 18:45:29
import pandas as pd def score_validation(row): try: assert 0<=row.Score<=100 except: print(f'Idx: {row.idx} StudentName: {row.Name} has an invalid score: {row.Score}') # 索引列:学员Id,数据列:学员姓名,学员成绩 studentsScores = pd.read_excel('D:/studentsScores.xlsx') # 使用pandas 校验分数 # 逐行校验数据, axis=1 按照行进行(数据是每行从左向右) # 逐行校验数据, axis=0 按照列进行(数据是每列从上到下) studentsScores.apply(score_validation, axis=1) print(studentsScores) 视频地址: https://www.bilibili.com/video/av88814463?p=17 来源: oschina 链接: https://my.oschina.net/ski/blog/3179566

matplotlib绘图库入门

亡梦爱人 提交于 2020-02-29 12:10:46
matplotlib 是python最著名的绘图库,它提供了一整套和matlab相似的命令API,十分适合交互式地行制图。而且也可以方便地将它作为绘图控件,嵌入GUI应用程序中。 它的文档相当完备,并且Gallery页面中有上百幅缩略图,打开之后都有源程序。因此如果你需要绘制某种类型的图,只需要在这个页面中浏览/复制/粘贴一下,基本上都能搞定。 在Linux下比较著名的数据图工具还有gnuplot,这个是免费的,Python有一个包可以调用gnuplot,但是语法比较不习惯,而且画图质量不高。 而 Matplotlib 则比较强:Matlab的语法、python语言、latex的画图质量(还可以使用内嵌的latex引擎绘制的数学公式)。 Matplotlib.pyplot快速绘图 快速绘图 和 面向对象方式绘图 matplotlib实际上是一套面向对象的绘图库,它所绘制的图表中的每个绘图元素,例如线条Line2D、文字Text、刻度等在内存中都有一个对象与之对应。 为了方便快速绘图matplotlib通过pyplot模块提供了一套和MATLAB类似的绘图API,将众多绘图对象所构成的复杂结构隐藏在这套API内部。我们只需要调用pyplot模块所提供的函数就可以实现快速绘图以及设置图表的各种细节。pyplot模块虽然用法简单,但不适合在较大的应用程序中使用。

吴恩达机器学习代码及相关知识点总结--ex3(1.神经网络)

﹥>﹥吖頭↗ 提交于 2020-02-28 21:07:18
python矩阵乘积运算(multiply/maumul/*/@)解析 1.加载数据 def load_data ( path , transpose = True ) : data = sio . loadmat ( path ) y = data . get ( "y" ) #before reshape:(5000, 1) y = y . reshape ( y . shape [ 0 ] ) X = data . get ( "X" ) #(5000,400),(400,) if transpose : #向量化,让每列为一个样本变为每行是一个样本? X = np . array ( [ im . reshape ( ( 20 , 20 ) ) . T for im in X ] ) X = np . array ( [ im . reshape ( 400 ) for im in X ] ) #将样本展开为原来的(400,) return X , y X , y = load_data ( 'code/ex3-neural network/ex3data1.mat' ) print ( X . shape ) print ( y . shape ) (5000, 400) (5000,) 2.画图 def plot_an_image ( image ) : fig ,

pandas 中axis=0

筅森魡賤 提交于 2020-02-28 15:20:24
axis=0说明是对某一个列的所有行进行处理 axis=1说明是对某一个行的所有列进行处理 来源: CSDN 作者: index、 链接: https://blog.csdn.net/qq_41196737/article/details/104550681

第十三章 Matplotlib库

对着背影说爱祢 提交于 2020-02-27 06:54:58
第十三章 Matplotlib库 数据可视化是数据分析的一个重要工具,掌声有请Matplotlib 13.0 环境配置 【1】 要不要plt.show() ipython中可用魔术方法 %matplotlib inline pycharm 中必须使用plt.show() % matplotlib inline import matplotlib . pyplot as plt plt . style . use ( "seaborn-whitegrid" ) # 设置下面都是用这种风格 x = [ 1 , 2 , 3 , 4 ] y = [ 1 , 4 , 9 , 16 ] plt . plot ( x , y ) plt . ylabel ( "squares" ) # plt.show() Text(0, 0.5, 'squares') 【2】设置样式 plt . style . available [ : 5 ] # 查看可以使用的风格 ['bmh', 'classic', 'dark_background', 'fast', 'fivethirtyeight'] with plt . style . context ( "seaborn-white" ) : # with代码块中使用这个风格 plt . plot ( x , y ) 【3】将图像保存为文件 import