您的位置:首頁技術文章
文章詳情頁

python 3.6 list(map())問題

瀏覽:86日期:2022-09-22 13:39:51

問題描述

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 循環來迭代。這樣的

python 3.6 list(map())問題

回答2:

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

標簽: Python 編程
相關文章:
国产综合久久一区二区三区