I currently have a dataframe like this:
Month Day Birthday
0 Jan 31 Yes
1 Apr 30 No
2 Mar 31 Yes
3 June 30 Yes
How would I select the columns dynamically and append them to another list? For example:
d= [Birthday, Month, Day, ...]
xx=[]
for f in range(len(d)):
loan = df[f].values.tolist()
xx.append(loan)
So that xx is the following:
[Yes,No,Yes,Yes,Jan,Apr,Mar,June,...]
Something like this but on a much larger scale.
I keep getting the following error:
KeyError: 0
When I try
for f in range(len(d)):
loan = df[d[f]].values.tolist()
I get
IndexError: list index out of range