Nour Eldin Megahed
Nour Eldin Megahed

Reputation: 95

Defining a column in an excel file using pandas

How do I select a column in an excel file and display it only by pandas I tried:

    videos = df.loc[:, df.columns == 'videos']
    videosvar = (videos.loc[num].values)
    print(videosvar)

Upvotes: 2

Views: 226

Answers (2)

jezrael
jezrael

Reputation: 862851

If need select by indice and column name use:

videosvar = df.loc[num, 'videos']

Upvotes: 1

Ashyam
Ashyam

Reputation: 696

You can select column by directly mentioning the column name.

videos_column = videosvar["videos"]  # returns the column as a series

Upvotes: 1

Related Questions