I have a big dataframe (df) X with n columns (~30000), ~2000 rows and column names like these:
A,B,C,D,F,G,H,v1,453,73v,4-5,ss,9-dd,...,n
The elements of X are a mix of integers, floats and strings.
Using python or unix/bash, I want to split X into n-7 dfs. Each resulting df will keep the first 7 columns from X + the next single column from X. Thus, the first 3 dfs will have the following columns:
A,B,C,D,F,G,H,v1
A,B,C,D,F,G,H,453
A,B,C,D,F,G,H,73v
and so on...
I want each of the resulting dfs to keep the name of its last column + ".txt". So, the first three df will be called "v1.txt", "453.txt" and "73v.txt".
This post is somehow similar to: Split huge file into n files keeping first 7 columns + next 3 columns until column n
but I am not able to adapt it.