Saturday, October 4, 2025
HomeLanguagesHow to import excel file and find a specific column using Pandas?

How to import excel file and find a specific column using Pandas?

In this article, we will learn how to import an excel file into a data frame and find the specific column. Let’s suppose our excel file looks like this.

Sample_data.xlsx

Excel sheet Link: https://drive.google.com/file/d/1x-S0z-gTo–H8byN12_MWLawlCXfMZkm/view?usp=sharing

Approach :

  • Import Pandas program
  • Create a DataFrame
  • Store Excel data into DataFrame
  • Check the specific column and display with head() function

Below is the implementation.

Step 1: Import excel file.

Python3




# importing module
import pandas as pd
  
  
# creating dataframe
# importing excel file
df = pd.read_excel('Sample_data.xlsx')  
df.head()


Output :

Step 2: Check the specific column and display topmost 5 value with the head()

Python3




df[df["Country"] == 'Canada'].head()


Output :

Another column with the same methods.

Python3




df[df["Year"] == 2013].head()


Output :

Another column with the same methods.

Python3




df[df["Segment"]=='Government'].head()


Output :

RELATED ARTICLES

Most Popular

Dominic
32335 POSTS0 COMMENTS
Milvus
86 POSTS0 COMMENTS
Nango Kala
6705 POSTS0 COMMENTS
Nicole Veronica
11870 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11934 POSTS0 COMMENTS
Shaida Kate Naidoo
6821 POSTS0 COMMENTS
Ted Musemwa
7086 POSTS0 COMMENTS
Thapelo Manthata
6779 POSTS0 COMMENTS
Umr Jansen
6778 POSTS0 COMMENTS