I have a DataFrame with named columns and rows indexed with not continuous numbers like from the code:
df1 = DataFrame(np.random.randn(10, 4), columns=['a', 'b', 'c', 'd'])
mask = df1.applymap(lambda x: x <-0.7)
df1 = df1[-mask.any(axis=1)]
sLength = len(df1['a'])
e = Series(np.random.randn(sLength))
I would like to add new column 'e' to the existing df and do not change anything in the df. (The series got always the same length as a dataframe.) I try different version of join
, append
, merge
but do not have this what I want, error at the most.
The series and df is already given and above code is only to illustrate example.
I am sure there is some easy way to that but can't figure it out