python 3.6 list(map())问题

 wurtjq 发布于 2022-10-26 17:24
map(lambda x: [ret_ttest.loc[x][0], ret_ttest.loc[x][1]], ret_ttest.index)

结果:

list(map(lambda x: [ret_ttest.loc[x][0], ret_ttest.loc[x][1]], ret_ttest.index))

报错:---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
----> 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()来转换吗

2 个回答
  • 这个map是惰性求值,返回的是类似一个迭代器的东西.看报错信息应该是你lambda表达式的问题,前一个不报错是因为没有执行.所以检查一下你传进去的lambda表达式是不是有问题.

    2022-10-27 01:18 回答
  • 用for 循环来迭代。
    这样的

    2022-10-27 01:18 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有