Traceback (most recent call last):
File "<pyshell#80>", line 1, in <module>
do_work()
File "C:\pythonwork\readthefile080410.py", line 14, in do_work
populate_frequency5(e,data)
File "C:\pythonwork\readthefile080410.py", line 157, in populate_frequency5
data=medications_minimum3(data,[drug.upper()],1)
File "C:\pythonwork\readthefile080410.py", line 120, in medications_minimum3
counter[row[11]]+=1
TypeError: unhashable type: 'list'
मैं इस लाइन पर उपरोक्त त्रुटि हो रही है:अजगर: unhashable प्रकार की त्रुटि
data=medications_minimum3(data,[drug.upper()],1)
(मैं भी कोशिश की है drug.upper() कोष्ठकों के बिना)
यहाँ एक पूर्वावलोकन है यह फ़ंक्शन:
def medications_minimum3(c,drug_input,sample_cutoff): #return sample cut off for # medications/physician
d=[]
counter=collections.defaultdict(int)
for row in c:
counter[row[11]]+=1
for row in c:
if counter[row[11]]>=sample_cutoff:
d.append(row)
write_file(d,'/pythonwork/medications_minimum3.csv')
return d
क्या कोई जानता है कि मैं यहां क्या गलत कर रहा हूं? क्योंकि मैं एक अलग स्थान से इस समारोह फोन
मुझे पता है कि क्या गलत किया जाना चाहिए, जिस तरह से मैं इस समारोह बोल रहा हूँ है और यह ठीक काम करता है:
d=medications_minimum3(c,drug_input,50)
आप आपकी मदद के लिए बहुत बहुत धन्यवाद!
की बजाय फ़ंक्शन विफल कॉल में '[drug.upper()]' के आसपास स्क्वायर ब्रैकेट क्यों है? –
और यह फ़ंक्शन में भी उपयोग नहीं किया जाता है, drug_input – jcubic
@jcubic का कोई संदर्भ नहीं है: अच्छा पकड़। इसका शायद मतलब है कि कोड को बेकार होने के लिए यहां पोस्ट करने के लिए बहुत अधिक संपादित किया गया है। –