We can access a single value for a row or column label of a DataFrame in Pandas with the help of the at attribute.
The at attribute is used to obtain a single value in a given DataFrame or Series.
The at attribute takes the syntax below.
DataFrame.at
As an attribute, at does not take a parameter value. It takes the index row and column labels of the desired value in the DataFrame.
The at attribute returns a single value in a DataFrame or Series.
import pandas as pd# creating a list of objectsint_values = [1, 2, 3, 4, 5]text_values = ['alpha', 'beta', 'gamma', 'delta', 'epsilon']float_values = [0.0, 0.25, 0.5, 0.75, 1.0]# creating a dataframe from the list of objectsdf = pd.DataFrame({"int_column": int_values, "text_column": text_values,"float_col": float_values})# printing the dataframeprint(df)# accessing the value "delta" present in the 4th row and in the "text_columnm" columna = df.at[3, "text_column"]print(a)
pandas library.text_values, int_values, and float_values.pandas.DataFrame(). The name of the DataFrame is df.df."delta", which is found in the 4th row (index 3) and on the "text_column" column. The value is passed to a variable, a.a.