+

Python | Pandas dataframe.get_value ()

The Pandas dataframe.get_value() function is used to quickly retrieve a single value in a dataframe in a passed column and index. The input to the function is a row label and a column label.

Syntax: DataFrame.get_value (index, col, takeable = False)

Parameters:
index: row label
col: column label
takeable: interpret the index / col as indexers, default False

Returns: value: scalar value

To link to the CSV file used by in the code, click here

Example # 1: Use get_value () to find the salary value on line 10

# import pandas as pd

import pandas as pd

  # Create data frame

df = pd.read_csv ( "nba.csv" )

 
# Print the data frame
df

# using the get_value () function

df.get_value ( 10 , ` Salary` )

Output:

Example # 2: Use get_value () and pass the column index value, not the name.

Note. We we can also use the integer indexer column value by setting takeable = True.

# import pandas as pd

import pandas as pd

 
# Create data frame

df = pd.read_csv ( "nba.csv" )

 
# index value of the “Name” column 0
# We set takeable = True
# interpret index / col as an indexer

df.get_value ( 4 , 0 , takeable = True )

Output:

Get Solution for free from DataCamp guru