Answer not matching the console

Screen Link:
https://app.dataquest.io/m/239/processing-and-transforming-features/3/dummy-coding

My Code:
dummy_cols = pd.DataFrame()

for i in text_cols:
train[i]=pd.get_dummies(train[i])

Replace this line with your code

What I expected to happen:

requisite changes must have been made in train set
What actually happened:
not happening

Replace this line with the output/error

I checked few of my columns using value counts to assert whether they do have requisite changes and they have but still my answer is not matching . what is wrong with my code ?

Focus on debugging your approach first

  1. Apply get_dummies to just one column in text_cols.
  2. See what the above outputs before you assign it to train[i], where i corresponds to that single column
  3. Then assign that to train[i] and print out train[i]
  4. Check if the outputs from the above two steps match or not.

Based on the above go through the content again to understand what exactly get_dummies does and think about what you may or may not be missing or have to do differently.

If you get stuck or can’t progress, then ask questions focusing on what you tried, what you understood, and where you are stuck.

1 Like

@the_doctor has a good approach also when posting here please do this

#Your code goes here

This way we can see what you have done

Secondly what can also help is using the solution code and work backwards from it