import pandas as pd
my_data = pd.read_excel('D:\student.xlsx')
print(my_data)
Output
id name class mark sex
0 1 John Deo Four 75 female
1 2 Max Ruin Three 85 male
2 3 Arnold Three 55 male
3 4 Krish Star Four 60 female
----------------
----------------
---------------
You can display all 35 rows , Now let us try our sample scripts.import pandas as pd
my_data = pd.read_excel('D:\student.xlsx')
print(my_data.at[1,'name']) # row 1, column='name'
Output
Max Ruin
We will set ( update ) the name at 2nd row. We will use at to first read the data at perticular location.
import pandas as pd
my_data = pd.read_excel('D:\student.xlsx')
# getting the name
print(my_data.loc[2].at['name']) # Arnold
print(my_data.at[2,'name']) # Arnold
Above code will display the name at row 2. Now let us update the name with Arnold2 and again read the data.
import pandas as pd
my_data = pd.read_excel('D:\student.xlsx')
# updatting data
my_data.at[2,'name']='Arnold2'
print(my_data.at[2,'name']) # Arnold2
Output
Arnold2
loc mask
where
query
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.