Task Description
If I have a list of DataFrames in say a_list
and each list looked like the following:
1 2 3
a x x x
b y y y
c z z z
I am interested in making each column of each DataFrame in a_list
into its own list.
So say b_list[0]
would be
1
a x
b y
c z
b_list[1]
would be
2
a x
b y
c z
etc.
I currently have around 150 DataFrames in a list with each having 30+ columns. So the desired list would have around b_list[4500]
Any help with this would be awesome!
Try this:
b_list = []
for df in a_list:
for col in df.columns:
b_list.append(df[[col]])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.