mars.dataframe.DataFrame.at#

DataFrame.at#

访问行/列标签对的单个值。

类似于 loc,因为两者都提供基于标签的查找。如果您只需要在 DataFrame 或 Series 中获取或设置单个值,请使用 at

Raises

KeyError – 如果“label”在DataFrame中不存在。

另请参阅

DataFrame.iat

通过整数位置访问行/列对的单个值。

DataFrame.loc

通过标签访问一组行和列。

Series.at

使用标签访问单个值。

示例

>>> import mars.dataframe as md
>>> df = md.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]],
...                   index=[4, 5, 6], columns=['A', 'B', 'C'])
>>> df.execute()
    A   B   C
4   0   2   3
5   0   4   1
6  10  20  30

获取指定行/列组合的值

>>> df.at[4, 'B'].execute()
2

# 在指定的行/列对上设置值 # # >>> df.at[4, ‘B’] = 10 # >>> df.at[4, ‘B’] # 10

获取序列中的值

>>> df.loc[5].at['B'].execute()
4