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
Try to use pandas.DataFrame.get (see docs):
pandas.DataFrame.get
import pandas as pd import numpy as np dates = pd.date_range('20200102', periods=6) df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list('ABCD')) df.get(['A','C'])