O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Selecting the columns of a DataFrame

Selecting the data in specific columns of a DataFrame is performed by using the [] operator. This differs from a Series, where [] specified rows. The [] operator can be passed either a single object or a list of objects representing the columns to retrieve.

The following retrieves the column with the name 'Sector':

When a single column is retrieved from a DataFrame, the result is a Series:

Multiple columns can be retrieved by specifying a list of column names:

Since this has multiple columns, the result ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required