0

I have a dataframe which has the Material Types Column. I have a dictionary for {'Material type, Value}.

Now when I try to add a column MAD_PER_MATERIAL using Dictionary mapping for the same column Material types, I am getting NANs in the new column formed.

d=b.set_index('Material_Types').to_dict()
df["MAD_PER_MATERIAL"] = df["MATERIAL_Types"].map(d)
cs95
  • 379,657
  • 97
  • 704
  • 746
Love Tyagi
  • 37
  • 5
  • 1) paste your data frame 2) paste your dictionary. – cs95 Jul 20 '17 at 01:08
  • This is an answer I gave on [**HowToMakeGoodExamples**](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples/38466059#38466059). In it I describe that your reputation is more than the points you've accumulated. Believe it or not, it takes effort to answer these questions. I enjoy doing it, but I also appreciate appreciation in the form of up-votes. And when I see that answers haven't been accepted when they should be, I remember that too. What that translates into is, I don't want to invest my time answering a question that won't get accepted. – piRSquared Jul 20 '17 at 01:30

0 Answers0