'Why is pd.series(cell_list) deleting the last elements of my cell_list?

My existing data frame 'error' is like this,

Bal1 Bal2 Bal3
1 2.0 1
3 NaN 3
I want to add a fourth column Bal4= [1,2,3,4,5] 

so, i do import pandas as pd

error['Bal4']= pd.Series(Bal4)

But then I get 'error' as

Bal1 Bal2 Bal3 Bal4
1 2.0 1 1
3 NaN 3 2

the rest 3,4,5 of Bal4 is getting deleted, why?



Solution 1:[1]

Try pd.concat

error = pd.concat([error, pd.DataFrame({'Bal4': Bal4})], axis=1)
print(error)

   Bal2  Bal3  Bal4
0   2.0   1.0     1
1   NaN   3.0     2
2   NaN   NaN     3
3   NaN   NaN     4
4   NaN   NaN     5

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ynjxsjmh