Click here to Skip to main content
15,747,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm getting "Unhashable Type : Index" error in python code. i'm using python3 .
Can you please help me to resolve this problem?

code-
Python
<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.
Posted
Updated 10-Apr-19 2:26am

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900