Click here to Skip to main content
14,270,795 members
Rate this:
Please Sign up or sign in to vote.
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-
<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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100