首頁  >  問答  >  主體

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()来转换吗

伊谢尔伦伊谢尔伦2740 天前927

全部回覆(2)我來回復

  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:21:00

    用for 迴圈來迭代。
    這樣的

    回覆
    0
  • 高洛峰

    高洛峰2017-04-18 10:21:00

    這個map是惰性求值,返回的是類似一個迭代器的東西.看報錯訊息應該是你lambda表達式的問題,前一個不報錯是因為沒有執行.所以檢查一下你傳進去的lambda表達式是不是有問題.

    回覆
    0
  • 取消回覆