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. boot2docker無法啟動2. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””3. docker-compose中volumes的問題4. javascript - mock.js可以存儲數據嗎5. nignx - docker內nginx 80端口被占用6. docker安裝后出現Cannot connect to the Docker daemon.7. java - SSH框架中寫分頁時service層中不能注入分頁類8. golang - 用IDE看docker源碼時的小問題9. docker api 開發的端口怎么獲???10. dockerfile - 為什么docker容器啟動不了?

網公網安備