- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to access a single value in pandas Series using the integer position?
The pandas.Series.iat attribute is used to access the single series element by using the position index value and It is very similar to the iloc in pandas instead of accessing a group of elements here we will access a single element.
The “iat” attribute takes an integer index value for getting and setting the element in a particular position. Let’s take some examples to access a single series element by using the “.iat” attribute.
import pandas as pd # create a series s = pd.Series([65, 66, 67, 68, 69, 70]) print(s) print('Output: ', s.iat)
In this following example, we have created a series using a python list and the index is auto-created integer values by pandas.Series constructor. Here the “4” is an index position s.iat used to get that positional element.
0 65 1 66 2 67 3 68 4 69 5 70 dtype: int64 Output: 69
In the same way, we can get any value using positional index data. For the above example, the output “69” is located in 4 index position.
import pandas as pd # create a series s = pd.Series([65, 66, 67, 68, 69, 70]) print(s) s.iat = 111 print('Output: ', s)
Now let’s update the value “111” at the 4th index position of a given pandas series “iat” attribute.
0 65 1 66 2 67 3 68 4 69 5 70 dtype: int64 Output: 0 65 1 66 2 67 3 68 4 111 5 70 dtype: int64
We successfully updated the value “111” at integer index position “4” by using the “.iat” property of the pandas.Series, we can observe both the series object in the above output block.
The “.iat” attribute will raise an “indexError” if the given integer index position is not found in the index range.
- How to access a single value in pandas DataFrame using the integer positions?
- How to access a single value in pandas Series using the .at attribute?
- How to access a single value in pandas Data Frame using the .at attribute?
- How to Get the Position of Max Value of a pandas Series?
- How to Get the Position of Minimum Value of a pandas Series?
- How to access pandas Series elements using the .iloc attribute?
- How to access pandas Series elements using the .loc attribute?
- How to access Pandas Series elements by using indexing?
- Python - How to access the last element in a Pandas series?
- How to apply integer division to the pandas series by a scalar?
- How to access datetime indexed elements in pandas series?
- How to access a group of elements from pandas Series using the .iloc attribute with slicing object?
- How to convert a single character to its integer value in Python?
- How to concrete a single Series into a string Python Pandas library?
- How to perform the Integer division operation of a pandas Series by a Python list?