I have a dataframe, df with columns headers A, B , C, D
can I reference these headers from this dictionary?
dic={'key1':['A','B'],
key2: [C,D]}
df[key1[0]]
giving the output of just column A?
A
0 44
1 44
2 44
3 33
I have a dataframe, df with columns headers A, B , C, D
can I reference these headers from this dictionary?
dic={'key1':['A','B'],
key2: [C,D]}
df[key1[0]]
giving the output of just column A?
A
0 44
1 44
2 44
3 33
Yes you can but you need
df[dic['key1']]
A B
0 NaN NaN
df[[dic['key1'][0]]]
A
0 NaN