numpy学习(一)
(一)基础学习
学习渠道:阿里天池AI学习——Numpy基础(传送门)
(二)练习篇
练习渠道:Numpy基础100题(Part 1)
1. Import the numpy package under the name np(★☆☆)
import numpy as np
2. Print the numpy version and the configuration(★☆☆)
print(np.version)
np.show_config()
3. Create a null vector of size 10(★☆☆)
arr = np.zeros(10)
print(arr)
运行结果:[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
4. How to find the memory size of any array (★☆☆)
print("%d bytes" %(arr.size*arr.itemsize))
运行结果:80 bytes
5. How to get the documentation of the numpy add function from the command line? (★☆☆)
np.add?
6. Create a null vector of size 10 but the fifth value which is 1 (★☆☆)
arr = np.zeros(10)
arr[4] = 1;
print(arr)
运行结果:[0. 0. 0. 0. 1. 0. 0. 0. 0. 0.]
7. Create a vector with values ranging from 10 to 49 (★☆☆)
arr = np.arange(10,50)
print(arr)
运行结果:[10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49]
8. Reverse a vector (first element becomes last) (★☆☆)
arr = np.arange(10,50)
print(arr[::-1])
运行结果:[49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10]
9. Create a 3x3 matrix with values ranging from 0 to 8 (★☆☆)
arr = np.arange(9).reshape(3,3)
print(arr)
运行结果:[[0 1 2] [3 4 5] [6 7 8]]
10. Find indices of non-zero elements from [1,2,0,0,4,0] (★☆☆)
arr = np.array([1,2,0,0,4,0])
print(arr.nonzero()[0])
运行结果:[0 1 4]
numpy学习(一)的更多相关文章
- NumPy学习笔记 三 股票价格
NumPy学习笔记 三 股票价格 <NumPy学习笔记>系列将记录学习NumPy过程中的动手笔记,前期的参考书是<Python数据分析基础教程 NumPy学习指南>第二版.&l ...
- NumPy学习笔记 二
NumPy学习笔记 二 <NumPy学习笔记>系列将记录学习NumPy过程中的动手笔记,前期的参考书是<Python数据分析基础教程 NumPy学习指南>第二版.<数学分 ...
- NumPy学习笔记 一
NumPy学习笔记 一 <NumPy学习笔记>系列将记录学习NumPy过程中的动手笔记,前期的参考书是<Python数据分析基础教程 NumPy学习指南>第二版.<数学分 ...
- 数据分析之Pandas和Numpy学习笔记(持续更新)<1>
pandas and numpy notebook 最近工作交接,整理电脑资料时看到了之前的基于Jupyter学习数据分析相关模块学习笔记.想着拿出来分享一下,可是Jupyter导出来h ...
- NumPy学习(索引和切片,合并,分割,copy与deep copy)
NumPy学习(索引和切片,合并,分割,copy与deep copy) 目录 索引和切片 合并 分割 copy与deep copy 索引和切片 通过索引和切片可以访问以及修改数组元素的值 一维数组 程 ...
- NumPy学习(让数据处理变简单)
NumPy学习(一) NumPy数组创建 NumPy数组属性 NumPy数学算术与算数运算 NumPy数组创建 NumPy 中定义的最重要的对象是称为 ndarray 的 N 维数组类型. 它描述相同 ...
- numpy 学习笔记
numpy 学习笔记 导入 numpy 包 import numpy as np 声明 ndarray 的几种方法 方法一,从list中创建 l = [[1,2,3], [4,5,6], [7,8,9 ...
- numpy 学习总结
numpy 学习总结 作者:csj更新时间:01.09 email:59888745@qq.com 说明:因内容较多,会不断更新 xxx学习总结: 回主目录:2017 年学习记录和总结 #生成数组/使 ...
- (转)Python数据分析之numpy学习
原文:https://www.cnblogs.com/nxld/p/6058572.html https://morvanzhou.github.io/tutorials/data-manipulat ...
- Numpy学习1
NumPy学习(1) 参考资料: http://www.cnblogs.com/zhanghaohong/p/4854858.html http://linusp.github.io/2016/02/ ...
随机推荐
- flex布局小结
2009年,W3C 提出了一种新的方案----Flex 布局,可以简便.完整.响应式地实现各种页面布局.目前,它已经得到了所有浏览器的支持. Flex 是 Flexible Box 的缩写,意为&qu ...
- OpenLayers 6 学习笔记
这个是真的学习笔记!不是教程 转载请声明:https://www.cnblogs.com/onsummer/p/12159366.html 基于openlayers 6.x api不太好查,就基于腾讯 ...
- html基本标签表单实现交互原理,单选框,复选框,下拉框介绍
表单是什么?表单是前端和服务器做交互的一种机制,表单收集用户输入信息,之后发送或者提交给服务器.用户在输入的信息称之为内容,内容的文本分为普通和密码型,用户通过单选框.复选框.下拉框(也就是下拉菜单) ...
- [CF1311C] Perform the Combo
Solution 前缀和搞一下即可 #include <bits/stdc++.h> using namespace std; #define int long long const in ...
- StackExchange.Redis 系列 1:基础使用
本系列博文已经全部完成,完整系列请访问:https://blog.zhuliang.ltd/tags/StackExchange-Redis%E7%B3%BB%E5%88%97/ 本文转自:https ...
- jQuery---钢琴案例 (按下1-9数字键,能触发对应的mouseenter事件)
钢琴案例 (按下1-9数字键,能触发对应的mouseenter事件) 1. 结合之前的学习,主要内容,就是on注册keyup事件,函数里传入e, 用e.keyCode,来获取1-9的数字的范围. 如果 ...
- Ubuntu禁用root账号,开启Ubuntu密钥登录
新建普通用户 ## 新建普通用户 $ adduser ubuntu $ apt-get install sudo ## 将用户加入sudo组 $ usermod -a -G sudo ubuntu 为 ...
- Socket通讯探索(二)-socket集群
前面我们在章节“Socket通讯探索(一)”中如何实现一个tcp连接,但是这仅仅是一个最初级的BIO实现,且没有添加线程池,实际应用中很少采用这种方式,因为不得不考虑当大量的Tcp连接建立的时候,服务 ...
- c#中for与foreach的使用
for循环示例: static void Main(string[] args) { string[] s = new string[] { "a,b,c,d,e,f,g" }; ...
- qt 带箭头的直线 (类似viso)
2020.02.27 本来上传到CSDN,后来想想,我要放弃csdn了.csdn已经跟我分享的精神背道而驰了.想要代码,留邮箱吧. 近来Qt开发时可能遇到这样的需求:两个(或多个)矩形,要用直线将它们 ...