Select multiple columns in a Pandas DataFrame

In Python, easily select multiple columns in a Pandas DataFrame. You can select more than one column without using built-in functions. More than two columns can also be selected in a range. In this lesson, learn how to:

  1. Select two columns
  2. Select multiple columns in a range

Select two columns

To select two specific columns from a Pandas DataFrame, mention the column names. Do not mention the column names you don’t want to display:

Let us see an example of selecting two specific columns in a Pandas DataFrame:

Output

Select multiple columns in a range

In a Pandas DataFrame, to select more than one column in a range, mention the index numbers in a range separated by a colon. The following selects columns 3rd to 5th

Let us see an example to select multiple columns in a range. We have added two more columns to the above example for our input:

Output


If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


For Videos, Join Our YouTube Channel: Join Now


 

Combine two Pandas series into one
Read Excel in Python Pandas
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading