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.
Reading value at cell data by using at
We can read the value at cell by using row and column by using at()
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