如何解决“不可用类型:索引” python3中的错误? [英] How to resolve "unhashable type : index" error in python3?
本文介绍了如何解决“不可用类型:索引” python3中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在python代码中遇到Unhashable Type:Index错误。我正在使用python3。
你能帮我解决这个问题吗?
code-
I'm getting "Unhashable Type : Index" error in python code. i'm using python3 .
Can you please help me to resolve this problem?
code-
<pre>
df_temp_cns = pd.read_excel(r"/nsmnt/NS_Exec_DSHBD/IS_IT_Demad_Perf/cns_weekly/SrcFile/JnJ_CNS_Weekly_No_Indication_WE_2019-01-25.xlsx", header=0, skiprows=0)
z = 0
for x in range(0,20): #movies_skip_rows.index:
if z > 24:
break
z = 0
for y in range(0,25):
m = df_temp_cns.iloc[x,y]
if pd.notnull(m):
z = z+1
# Read the pivot table from excel
df_cns = pd.read_excel(r"/nsmnt/NS_Exec_DSHBD/IS_IT_Demad_Perf/cns_weekly/SrcFile/JnJ_CNS_Weekly_No_Indication_WE_2019-01-25.xlsx", header=0, skiprows=x+1)
# De-pivot data and rename columns
df_cns_depivot = pd.melt(df_cns, id_vars=df_cns.columns[0],value_vars=df_cns.columns[1:], value_name="Units")
我在下面收到错误 -
I'm getting error in below line-
<pre lang="Python">df_cns_depivot = pd.melt(df_cns, id_vars=df_cns.columns[0],value_vars=df_cns.columns[1:], value_name="Units")
我的尝试:
我尝试过很多东西,但没有解决这个问题。
What I have tried:
I tried many thing but didn't resolve this problem.
推荐答案
参见< a href =https://thispointer.com/select-rows-columns-by-name-or-index-in-dataframe-using-loc-iloc-python-pandas/>选择Rows&使用loc& ;;在DataFrame中按名称或索引列iloc | Python Pandas - thispointer.com [ ^ ]。
这篇关于如何解决“不可用类型:索引” python3中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文