Click here to Skip to main content
14,272,438 members

How to resolve "unhashable type : index" error in python3?

Member 11907260 asked:

Open original thread
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.
Tags: Python3.3

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100