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表達式是不是有問題.
相關文章:
