Length of values does not match length of index

892 views
Skip to first unread message

onyx

unread,
Jul 17, 2015, 9:35:14 AM7/17/15
to pyd...@googlegroups.com
Hello,

I am trying to copy an array of 15  elements into a pandas data frame having 96 columns and i get the error lenght of values does not match lenght of index. Is there a way to bypass this check and copy it leaving the blank spaces?

The code below gives me the error:

q = numpy.array(q)
for i in q.flat:
    print i
    i.astype(int)
     new = df2.copy() # df2 is my df2 = pandas.DataFrame(file)
    #new['Bin'] = numpy.insert(q,1,5)

When I just do this below only one vale of the array is populated over the 96 columns. I would like for it to copy the 15 elements into the 96 columns and leave the other columns.

#repeats only one value
for t in q:
    new['Bin'] = t

Kindly point me in the right direction.
Reply all
Reply to author
Forward
0 new messages