pyspark.pandas.DataFrame.at¶
-
property
DataFrame.
at
¶ Access a single value for a row/column label pair. If the index is not unique, all matching pairs are returned as an array. Similar to
loc
, in that both provide label-based lookups. Useat
if you only need to get a single value in a DataFrame or Series.Note
Unlike pandas, pandas-on-Spark only allows using
at
to get values but not to set them.Note
Warning: If
row_index
matches a lot of rows, large amounts of data will be fetched, potentially causing your machine to run out of memory.- Raises
- KeyError
When label does not exist in DataFrame
Examples
>>> psdf = ps.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]], ... index=[4, 5, 5], columns=['A', 'B', 'C']) >>> psdf A B C 4 0 2 3 5 0 4 1 5 10 20 30
Get value at specified row/column pair
>>> psdf.at[4, 'B'] 2
Get array if an index occurs multiple times
>>> psdf.at[5, 'B'] array([ 4, 20])