This script :
for x in df.index:
if df.loc[x,'medicament1'] in dicoprix:
df.loc[x,'coutmed1'] = dicoprix[df.loc[x,'medicament1']]
gives this error :
File "<ipython-input-35-097fdb2220b8>", line 3, in <module>
df.loc[x,'coutmed1'] = dicoprix[df.loc[x,'medicament1']]
File "//anaconda/lib/python2.7/site-packages/pandas/core/indexing.py", line 115, in __setitem__
self._setitem_with_indexer(indexer, value)
File "//anaconda/lib/python2.7/site-packages/pandas/core/indexing.py", line 346, in _setitem_with_indexer
value = self._align_series(indexer, value)
File "//anaconda/lib/python2.7/site-packages/pandas/core/indexing.py", line 613, in _align_series
raise ValueError('Incompatible indexer with Series')
ValueError: Incompatible indexer with Series
But the script is working, meaning df.loc[x,'coutmed1']
takes the value that I want.
I don't understand what am I doing wrong ?
I think that the problem comes from this
dicoprix[df.loc[x,'medicament1']]
This problem occurs when a key in the dict refers to more than one value !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With