Use of df.append in pandas with python

ipython

#1

Hello,
I tried to join a series at the end of a dataframe as follows:
df = pd.DataFrame(np.random.randn(8,4),columns=[‘a’,‘b’,‘c’,‘d’])
print df
:smile: = pd.Series([1,2,34,4])
df.append(s,ignore_index=True)

and obtained result as shown :

instead last row should be just below the 7 th row
Thanks


#2

Hey,
If you carefully analyze your code your series still has index[0,1,2,3] instead of the required one which is [‘a’,‘b’,‘c’,‘d’]. Just add the index as follows:

s = pd.Series([1,2,34,4],index=[‘a’,‘b’,‘c’,‘d’])

Hope this helps :smile:
thankyou