Friday, June 12, 2026
HomeLanguagesReading specific columns of a CSV file using Pandas

Reading specific columns of a CSV file using Pandas

Let us see how to read specific columns of a CSV file using Pandas. This can be done with the help of the pandas.read_csv() method. We will pass the first parameter as the CSV file and the second parameter the list of specific columns in the keyword usecols. It will return the data of the CSV file of specific columns.

Example 1: Link of the CSV file used: link

Python3




# importing the module
import pandas as pd
  
# read specific columns of csv file using Pandas
df = pd.read_csv("student_scores2.csv", usecols = ['IQ','Scores'])
print(df)


Output 
 

Example 2: Link of the CSV file used: link
 

Python3




# importing the module
import pandas as pd
  
# read specific columns of csv file using Pandas 
df = pd.read_csv("student.csv", usecols = ['Hours','Scores','Pass'])
print(df)


Output 
 

Example 3: Link of the CSV file used: link

Python3




# importing the module
import pandas as pd
  
 # read specific columns of csv file using Pandas
df = pd.read_csv("titanic.csv", usecols = ['Survived','Pclass'])
print(df)


Output:
 

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS