Valueerror: length of values does not match length of index on replacing value
Answers
Value error occurs when there is an error in the value that has been inputted.
Every field has a fixed field length.
As the error says, the length does not match the length of the index.
That is, it the length is too long or too short.
When the length is fixed in the index, the exact length should be entered in the fields.
This error can be debugged by entering the value in the correct specified length.
Answer:
Step-by-step explanation:
The ValueError: Length of values does not match length of index raised because the previous columns you have added in the DataFrame are not the same length as the most recent one you have attempted to add in the DataFrame. So, you need make sure that the length of the array you are assign to a new column is equal to the length of the dataframe. Another solution is that you first convert the list/array to a pandas Series , and then when you do assignment, missing index in the Series will be filled with NaN values .
http://net-informations.com/ds/err/length.htm