I attached an empty list of Dataframes into a variable. I used it in a for loop along with a list of columns so that I can transpose the columns into the index.
Then reassigned it back into the elements (the empty Dataframes). However, when I check it. The Dataframes are still empty. Why is that and how do I go about fixing it?
ex1 = pd.DataFrame({'col one':[100,200],'col two':[300,400]})
cols_list = ['col one', 'col two']
ex2 = pd.DataFrame()
ex3 = pd.DataFrame()
newdf_lists = [ex3, ex4]
for newdf_list, col_list in zip(newdf_lists, cols_list):
newdf_list = ex1[col_list]
newdf_list = newdf_list.transpose()
ex3
The result I get is:
__
The output I want is:
0 1
col one 100 200
col two 300 400