Asked • 05/19/19

Adding new column to existing DataFrame in Python pandas?

I have the following indexed DataFrame with named columns and rows not- continuous numbers: a b c d 2 0.671399 0.101208 -0.181532 0.241273 3 0.446172 -0.243316 0.051767 1.577318 5 0.614758 0.075793 -0.451460 -0.012493I would like to add a new column, `'e'`, to the existing data frame and do not want to change anything in the data frame (i.e., the new column always has the same length as the DataFrame). 0 -0.335485 1 -1.166658 2 -0.385571 dtype: float64I tried different versions of `join`, `append`, `merge`, but I did not get the result I wanted, only errors at most. How can I add column `e` to the above example?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.