You are viewing documentation about an older version (1.22.1). View latest version

modin.pandas.DataFrame.get¶

DataFrame.get(key, default=None)[source]¶

Get item from object for given key (ex: DataFrame column).

Returns default value if not found.

Parameters:

key (object) –

Return type:

same type as items contained in object

Examples

>>> df = pd.DataFrame(
...     [
...         [24.3, 75.7, "high"],
...         [31, 87.8, "high"],
...         [22, 71.6, "medium"],
...         [35, 95, "medium"],
...     ],
...     columns=["temp_celsius", "temp_fahrenheit", "windspeed"],
...     index=pd.date_range(start="2014-02-12", end="2014-02-15", freq="D"),
... )
Copy
>>> df
            temp_celsius  temp_fahrenheit windspeed
2014-02-12          24.3             75.7      high
2014-02-13          31.0             87.8      high
2014-02-14          22.0             71.6    medium
2014-02-15          35.0             95.0    medium
Copy
>>> df.get(["temp_celsius", "windspeed"])
            temp_celsius windspeed
2014-02-12          24.3      high
2014-02-13          31.0      high
2014-02-14          22.0    medium
2014-02-15          35.0    medium
Copy
>>> ser = df['windspeed']
>>> ser.get('2014-02-13')
2014-02-13    high
Freq: None, Name: windspeed, dtype: object
Copy
>>> ser.get('2014-02-10', '[unknown]')
Series([], Freq: None, Name: windspeed, dtype: object)
Copy

Notes

Generally Snowpark pandas won’t raise KeyError or IndexError if any key is not found. So the result of get will be a result with existing keys or an empty result if no key is found. Default value won’t be used.