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,現(xiàn)在map對象不是在外面添加list()來轉(zhuǎn)換嗎
問題解答
回答1:用for 循環(huán)來迭代。這樣的
這個map是惰性求值,返回的是類似一個迭代器的東西.看報錯信息應該是你lambda表達式的問題,前一個不報錯是因為沒有執(zhí)行.所以檢查一下你傳進去的lambda表達式是不是有問題.
相關文章:
1. android-studio - Android Studio 運行項目的時候一堆警告,跑步起來!?2. dockerfile - [docker build image失敗- npm install]3. mysql - 新浪微博中的關注功能是如何設計表結構的?4. angular.js使用$resource服務把數(shù)據(jù)存入mongodb的問題。5. 如何解決Centos下Docker服務啟動無響應,且輸入docker命令無響應?6. angular.js - 關于$apply()7. MySQL數(shù)據(jù)庫中文亂碼的原因8. 表單提交驗證,沒反應,求老師指點9. nignx - docker內(nèi)nginx 80端口被占用10. angular.js - Ionic 集成crosswalk后生成的apk在android4.4.2上安裝失敗???
