python 3.6 list(map())问题
问题描述
map(lambda x: [ret_ttest.loc[x][0], ret_ttest.loc[x][1]], ret_ttest.index)
结果:<map at 0x1e00aa38ef0>
list(map(lambda x: [ret_ttest.loc[x][0], ret_ttest.loc[x][1]], ret_ttest.index))
报错:---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-34-83f4c7c19c94> in <module>()----> 1 ret_ttest_df = list(map(lambda x: ret_ttest.loc[x, ret_ttest.locx], ret_ttest.index))
TypeError: ’list’ object is not callable
前几天升级了3.6,现在map对象不是在外面添加list()来转换吗
问题解答
回答1:用for 循环来迭代。这样的

这个map是惰性求值,返回的是类似一个迭代器的东西.看报错信息应该是你lambda表达式的问题,前一个不报错是因为没有执行.所以检查一下你传进去的lambda表达式是不是有问题.
相关文章:
1. 修改mysql配置文件的默认字符集重启后依然不生效2. angular.js - 关于指令link 中的创建变量问题3. mongodb - windows7下mongod无法正常启动4. 请问一下各位老鸟 我一直在学习独孤九贱 现在是在tp5 今天发现 这个系列视频没有实战5. php - 类似Apple官网顶部3级导航该如何设计数据库?6. javascript - ueditor引入报错问题7. python sqlite3 长语句插入出错8. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””9. Python两个list互换,两种不同的操作结果有差异,原因是什么呢?10. mysql - 请教一个Java做数据库缓存的问题

网公网安备