Python学习笔记
来源:互联网 发布:视频特效素材软件 编辑:程序博客网 时间:2024/05/18 02:05
1、多维数组转置
2、a = np.array([[[1, 2, 3],[4, 5, 6],[7, 8, 9]]])
b=a.T()
TypeError: 'numpy.ndarray' object is not callable
T()用法不对
3、列表数据类型转换后,dtype显示没变的原因
arr = np.array([2.3, 3.2, -1.4, 2.3])
arr.astype(np.int32)
In[36]:
arr.dtype
Out[36]:
dtype('float64')
astype方法复制了该ndarray数组,并且在复制的数组中进行转换,但是不会修改原数组。
4、匿名函数:lamda、reduce、map、filter
http://www.cnblogs.com/evening/archive/2012/03/29/2423554.html
>>> foo = [2, 18, 9, 22, 17, 24, 8, 12, 27]
>>>
>>> print filter(lambda x: x % 3 == 0, foo)
[18, 9, 24, 12, 27]
>>>
>>> print map(lambda x: x * 2 + 10, foo)
[14, 46, 28, 54, 44, 58, 26, 34, 64]
>>>
>>> print reduce(lambda x, y: x + y, foo)
5、python编程.为什么reduce函数在3.1环境下不能用了?
在Python 3里,reduce()函数已经被从全局名字空间里移除了,它现在被放置在fucntools模块里
用的话要 先引入
from functools import reduce
2、a = np.array([[[1, 2, 3],[4, 5, 6],[7, 8, 9]]])
b=a.T()
TypeError: 'numpy.ndarray' object is not callable
T()用法不对
3、列表数据类型转换后,dtype显示没变的原因
arr = np.array([2.3, 3.2, -1.4, 2.3])
arr.astype(np.int32)
In[36]:
arr.dtype
Out[36]:
dtype('float64')
astype方法复制了该ndarray数组,并且在复制的数组中进行转换,但是不会修改原数组。
4、匿名函数:lamda、reduce、map、filter
http://www.cnblogs.com/evening/archive/2012/03/29/2423554.html
>>> foo = [2, 18, 9, 22, 17, 24, 8, 12, 27]
>>>
>>> print filter(lambda x: x % 3 == 0, foo)
[18, 9, 24, 12, 27]
>>>
>>> print map(lambda x: x * 2 + 10, foo)
[14, 46, 28, 54, 44, 58, 26, 34, 64]
>>>
>>> print reduce(lambda x, y: x + y, foo)
5、python编程.为什么reduce函数在3.1环境下不能用了?
在Python 3里,reduce()函数已经被从全局名字空间里移除了,它现在被放置在fucntools模块里
用的话要 先引入
from functools import reduce
阅读全文
0 0
- 【python】:python学习笔记
- Python学习笔记-Python起步
- Python学习笔记-Python基础
- Python学习笔记-Python对象
- Python基本概念--Python学习笔记
- Python学习笔记:Python函数
- python学习笔记-python安装
- Python学习笔记--Python基础
- 【Python】python基础学习笔记
- python学习笔记3
- Python学习笔记
- Boost.Python学习笔记
- python学习笔记1
- python学习笔记2
- python学习笔记(2)
- Python学习笔记 Module
- Python学习笔记.
- python学习笔记(1)
- 模板实现顺序表
- 从输入url到页面展示到底发生了什么
- Asp.Net Core-使用Entity Framework
- Oracle 查看表空间的大小及使用情况sql语句(oracle数据库维护精品)
- 【Leetcode-easy-543】Diameter of Binary Tree
- Python学习笔记
- MFC框架界面开发(二):框架界面的分隔窗口
- Linux操作系统课后参考答案
- c++11标准线程库用法总结
- 二分查表(又称:折半查表)
- 坚持#第214天~零基础自学云计算基础语言应用11~15节
- ClassNotFoundException:MappingJacksonHttpMessageConverter
- Android游戏入门 SurfaceView应用----手指发动小球
- 最优装载问题(贪心基础)