Python学习笔记

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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值