Reputation: 71
So Im trying to add a new column using panda with this
print(sorted(v, reverse=True))
df['VALUE'] = [np.array([v])]
df.to_excel('E:/.../result.xlxs')
and error with message: ValueError Length of values does not match length of index
But when I check the number of elements from each with this code
jkl = len(alt)
lkj = len(v)
print(jkl == lkj)
the value is TRUE
Upvotes: 1
Views: 1093
Reputation: 758
May try to omit the extra square brackets around and inside the [np.array([v])]
expression and write it like this: np.array(v)
. With them it makes it a length 1 list, without them it should match the length you checked in the second code block.
Upvotes: 2