python 3.6 list(map())問題
問題描述
map(lambda x: [ret_ttest.loc[x][0], ret_ttest.loc[x][1]], ret_ttest.index)
結(jié)果:<map at 0x1e00aa38ef0>
list(map(lambda x: [ret_ttest.loc[x][0], ret_ttest.loc[x][1]], ret_ttest.index))
報(bào)錯(cuò):---------------------------------------------------------------------------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
前幾天升級(jí)了3.6,現(xiàn)在map對(duì)象不是在外面添加list()來轉(zhuǎn)換嗎
問題解答
回答1:用for 循環(huán)來迭代。這樣的

這個(gè)map是惰性求值,返回的是類似一個(gè)迭代器的東西.看報(bào)錯(cuò)信息應(yīng)該是你lambda表達(dá)式的問題,前一個(gè)不報(bào)錯(cuò)是因?yàn)闆]有執(zhí)行.所以檢查一下你傳進(jìn)去的lambda表達(dá)式是不是有問題.
相關(guān)文章:
1. javascript - 關(guān)于類的一個(gè)小問題,求解答?2. android百度地圖定位問題3. android - 圖片列表分組之后復(fù)用問題4. python - django models 為生成的html元素添加樣式。5. nginx bind failed6. android - 有數(shù)據(jù)要處理的時(shí)候如何使用rxJava進(jìn)行異步處理數(shù)據(jù)7. javascript - 關(guān)于圣杯布局的一點(diǎn)疑惑8. html5 - Chrome訪問本地文件緩慢9. python - angular route 與 django urls 沖突怎么解決?10. javascript - mongodb怎么設(shè)置用戶的賬戶不重復(fù)?

網(wǎng)公網(wǎng)安備