0
for i in range(len(a)):
    train[train.enrollee_id==a[i]]['enrolled_university']=train[train.enrollee_id==a[i]]['enrolled_university'].fillna(y_pred[I],inlace=True)
    print(train[train.enrollee_id==a[i]]['enrolled_university’])

112 NaN

Name: enrolled_university, dtype: float64

191 NaN

Name: enrolled_university, dtype: float64

244 NaN

Name: enrolled_university, dtype: float64

284 NaN

Name: enrolled_university, dtype: float64

315 NaN

Name: enrolled_university, dtype: float64

401 NaN

Name: enrolled_university, dtype: float64

VaibhavSka
  • 25
  • 1
  • 7
  • First off you are using chaining... this is a big "no-no" in pandas. You can quickly recognize chaining when you see this "] \[", there are other ways to select locations in pandas dataframes. [see docs](https://pandas.pydata.org/pandas-docs/stable/indexing.html?highlight=chaining#why-does-assignment-fail-when-using-chained-indexing) – Scott Boston Jul 18 '18 at 18:38
  • 1
    Possible duplicate of [Pandas: Chained assignments](https://stackoverflow.com/questions/21463589/pandas-chained-assignments) – xyzjayne Jul 18 '18 at 18:39
  • ok,I am understanding that what you are trying to say @ScottBoston but can you tell then what should I do to store my value at my desired location as I have a conditional statement also, I am a bit newbie at this and your help would be greatly appreciated – VaibhavSka Jul 18 '18 at 18:43
  • 1
    @VaibhavSka this is why Scott posted a link to the documentation... – xyzjayne Jul 18 '18 at 18:51

0 Answers0