V3.5.3版本的PYTHON
jupyter notebook中輸入:
df = pd.DataFrame(np.random.randint(0,100,size = (6,6)), index = list('ABCDEF'), columns = pd.MultiIndex.from_product([['Python','En','Math'],['期中',['期末']]]))
df
報錯:TypeError: unhashable type: 'list'
查了一下,list型別不可哈希,請問如何設定行索引為串列型別呢?還有,為啥別人的V3.6.5版本的PYTHON就不報錯呢?
uj5u.com熱心網友回復:
df = pd.DataFrame(np.random.randint(0,100,size = (6,6)), index = list('ABCDEF'), columns = pd.MultiIndex.from_product([['Python','En','Math'],['期中','期末']]))
應該是這樣的吧,你在期末兩邊多加了方括號
uj5u.com熱心網友回復:
明白了,又是個低級失誤
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/73593.html
上一篇:關于王爽的匯編語言中的一個問題
