Get elements from lists in pandas dataframe
You logic is correct, it's just the lambda function that is slightly wrong. .append() adds a single element to the end of the list, so in your case I guess it adds an element which is a list of 20 elements. You could either use .extend() instead, which will do what you want or you can simply write 

lambda x: x[:20] + x[-20:]