Pandas DataFrame at


Youtube Live session on Tkinter

Pandas

We used DataFrame of 35 rows by reading from a Excel file, you can download and check our student.xlsx file here.
Read more on how to read excel file here
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()
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

Pandas Pandas DataFrame iloc - rows and columns by integers
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer