Code Sample, a copy-pastable example if possible
temp = "['A', 'B']" transactions[temp]
Problem description
I am trying to use a string as an index of dataframe. Here if I write transactions[['A', 'B']] the code runs ,but when I write the same thing into a string and pass it as an index it does not work.
Expected Output
I want to display a dataframe including both the columns.
Comment From: jorisvandenbossche
Python doesn't work like this, you need to pass an actual list, not a string representation of this. If you really want to do something like this, you can pass temp
to eval
first, but I would not really recommend that.
Closing as this is not a pandas issue or bug.