I want to duplicate a list in a list of list with header. The list of list is coming from a list =[pandas.read_excel(file, header=['a','b']) for file in files]
to read multiple excel files.
So I have list = [[first_list], [second_list], [third_list], ...]
All the lists have the same header.
I want to duplicate the second list (and only this one) to have :
list = [[first_list], [second_list], [second_list], [third_list], ...]
What is the best way to do it ?
CodePudding user response:
If you have a list with at least 2 elements called my_list
, you can do:
my_list.insert(2, my_list[1])