np.newaxis 功能:为numpy.ndarray(多维数组)增加一个轴 np.newaxis 在使用和功能上等价于 None,查看源码发现:newaxis = None,其实就是 None 的一个别名. 举例: 原始数据 x_data = np.linspace(-1,1,5) print(x_data,x_data.shape) 用np.newaxis加新的轴和用None加新的轴得到的结果一致 x1_data = np.linspace(-1,1,5)[:,np.newaxis] pr…
x1[:,np.newaxis]:增维,转置 从字面上是插入新的维度的意思 demo1: 针对一维的情况 >>> b = np.array([1, 2, 3, 4, 5, 6]) >>> b[np.newaxis] array([[1, 2, 3, 4, 5, 6]]) >>> c = b[np.newaxis] #equals c = b[np.newaxis,:] >>> b.shape (6,) >>> c.s…
Pandas基础(全) 引言 Pandas是基于Numpy的库,但功能更加强大,Numpy专注于数值型数据的操作,而Pandas对数值型,字符串型等多种格式的表格数据都有很好的支持. 关于Numpy的基础知识,请查看 Numpy基础(全) 内容介绍 1.数据结构(Series,DataFrame) 2.索引对象 3.索引操作 4.数据运算 5.层次化索引 6.可视化(暂时忽略) 一,数据结构 Pandas 采用了很多Numpy的代码风格,但Pandas是用来处理表格型或异质性数据的,而Numpy…
1.dict is not callable tree是一个字典类型. tree("left") -> tree["left"]   2.list indices must be integers or slices, not tuple dataset是原生的python数组,是list类型(python原生数组叫list类型) errorMerge = sum(power(dataset[:, -1] - treeMean, 2)) 尝试使用numpy里面…
1 引言 TensorFlow2.0版本已经发布,虽然不是正式版,但预览版都发布了,正式版还会远吗?相比于1.X,2.0版的TensorFlow修改的不是一点半点,这些修改极大的弥补了1.X版本的反人类设计,提升了框架的整体易用性,绝对好评! 不多说了,赶紧来学习一波吧,做最先吃螃蟹的那一批人!先从TensorFlow的基本数据结构——张量(tensor)开始. 2 创建 2.1 constant()方法 >>> import tensorflow as tf >>>…
Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. The painting is a…
题目链接: B. Restoring Painting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he…
B. Restoring Painting 题目连接: http://www.codeforces.com/contest/675/problem/B Description Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he h…
OpenPyXl的使用 开始在内存中使用 创建一个workbook 在刚开始使用openpyxl的时候,不需要直接在文件系统中创建一个文件,仅仅需要导入Workbook类并开始使用它: >>> from openpyxl import Workbook >>> wb = Workbook() 一个workbook总是会创建至少一个worksheet(工作表),可以通过openpyxl.workbook.Workbook.active()这个属性去获取: >>…
numpy 简介 numpy的存在使得python拥有强大的矩阵计算能力,不亚于matlab. 官方文档(https://docs.scipy.org/doc/numpy-dev/user/quickstart.html) Quickstart tutorial Prerequisites Before reading this tutorial you should know a bit of Python. If you would like to refresh your memory,…