Guided Project: Exploring Ebay Car Sales Data. How to add a column to dataframe?

How to add a column to dataframe?

I tried code below but instead of values I got dictionary names added to the column and they are not even matching.

Hi @gaoweidong999: perhaps you could refer to this article on how you could do so.

Hope this helps!

1 Like

[email protected]@gaoweidong999, I think what you are trying to do is to add mileage as column matching the brand for each row of prices. one way you can do is to firstly turn mileage_dict into dataframe and merge the two dataframe on left.

Try this code:
mileage_df = pd.DataFrame.from_dict(mileage_dict)
df = pd.merge(df, mileage_df, how=‘left’)

1 Like