What is pandas.at() Method in Pandas?

Learn via video courses
Topics Covered

The Pandas at() function is one of the most frequently used functions that returns us the data located at the provided location. The Pandas at() function takes the location of data present in the DataFrame in the format - DataFrame.at[position, column-name].

We have another similar function in the Pandas function, i.e., loc(), which is used to retrieve any particular value from a row or column using index values. The Pandas at() function is faster than the Pandas loc() function. Since the at() function returns a single value, it is faster than the loc() function.

The Pandas library also provides us with a property that helps us to access the single value using the row or column pair.

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Syntax

The syntax of the Pandas at() function is quite simple. We just pass the row position and the column label to the function.

The syntax is:

Parameters

The Pandas at() method takes two parameters, namely-

  1. row-index: It tells the function the index value of the row that is to be searched.
  2. column-name: It tells the function of the column label in which the provided row has to be looked for.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science

Return Value

The Pandas at() function returns the single element present at the provided position. The at() function will take the intersection value and then returns the element present at the generated position.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Errors

The Pandas at() function raises the Key Error if the provided row index is out of the bound. Similarly, if the provided column label is not found or out of the bound, it raises the Key Error.

Examples

Let us take some examples to understand the Pandas at() function better.

1. Getting and setting the value using the at() function in Pandas.

Let us first create a DataFrame and then access a certain position using the at() function. We will then change the value of a position using the same at() function. The getting and setting feature of the at() function makes it similar to getters and setters functions.

Code:

Output:

2. Key Error generated due to out of bound.

Let us first create a DataFrame and then access a certain position using the at() function. We will then try to access a certain position that is not present in the dataFrame. So, the Pandas at() function will raise an Error.

Code:

Output:

Similarly, if we try to access a column that is not present, the Key error is generated.

Code:

Output:

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Conclusion

  • The Pandas at() function is one of the most frequently used functions that return us the data located at the provided location.
  • The Pandas at() function takes the location of data present in the DataFrame in the format - DataFrame.at[position, column-name].
  • The Pandas library also provides us with the property which helps us to access the single value using the row or column pair.
  • The Pandas at() method takes two parameters, namely- row-index, which tells the function the index value of the row that is to be searched, and the column-name, which tells the function the column-label in which the provided row has to be looked for.
  • The Pandas at() function returns the single element present at the provided position. The Pandas at() function raises the Key Error if the provided row index is out of the bound. Similarly, if the provided column label is not found or out of the bound, it raises the Key Error.