Python Pandas dataframe.get_value()
Python是一种进行数据分析的伟大语言,主要是因为以数据为中心的Python软件包的奇妙生态系统。_Pandas _是这些包中的一个,使导入和分析数据变得更加容易。Pandas dataframe.get_value()函数用于快速检索数据框架中位于传递的列和索引处的单个值。该函数的输入是行标和列标。
语法:
DataFrame.get_value(index, col, takeable=False)
参数:
- index : 行标签
- col : 列标签
- takeable : 将索引/col解释为索引器,默认为False
返回:值:标量值
例子#1:使用get_value()函数查找第10行中的工资值。
# importing pandas as pd
import pandas as pd
# Creating the dataframe
df = pd.read_csv("nba.csv")
# Print the dataframe
df
# applying get_value() function
df._get_value(10, 'Salary')
输出:
示例#2:使用get_value()函数并传递列的索引值而不是名称。注意:我们也可以通过设置takeable参数=True来使用列的整数索引值。
# importing pandas as pd
import pandas as pd
# Creating the dataframe
df = pd.read_csv("nba.csv")
# column index value of "Name" column is 0
# We have set takeable = True
# to interpret the index / col as indexer
df.get_value(4, 0, takeable = True)
输出: