Hello all. Why is my dimension-matching Series object not able to be used to populate these columns? Odder even is the fact that by forcing an index subscript, I get a non-failure (though not the result I truly want).
0 [John, Q, Public]
1 [Mark, K, Smith]
Name: Name, dtype: object
Name first middle last
0 John Q Public John Q Public
1 Mark K Smith John Q Public
...
ValueError: Columns must be same length as key
When you use the apply method, it creates a Series, which means only one dimension, each element is a list.
When you try to assign to the DataFrame, pandas coerce the Series to a DataFrame, with just one column, each row being a list. So the dimensions don’t match.
When you select one element of the Series, you get a list with 3 elements.
When you try to assign to the DataFrame, pandas coerces the list to a DataFrame with 3 columns and one row. Now the dimensions match, pandas assign this row to every row on the original DataFrame.