Home » Python » Selecting multiple columns in a pandas dataframe

Selecting multiple columns in a pandas dataframe

Posted by: admin October 4, 2018 Leave a comment

Questions:

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

How do I select 'b', 'c' and save it in to df1?

I tried

df1 = df['a':'b']
df1 = df.ix[:, 'a':'b']

None seem to work.

Answers: