I have data in different columns but I don\'t know how to extract it to save it in another variable.
index a b c 1 2 3 4 2 3 4 5
I realize this question is quite old, but in the latest version of pandas there is an easy way to do exactly this. Column names (which are strings) can be sliced in whatever manner you like.
columns = ['b', 'c'] df1 = pd.DataFrame(df, columns=columns)