Answers for "pd.loc"

5

pd.loc

>>> df = pd.DataFrame([[1, 2], [4, 5], [7, 8]],
...      index=['cobra', 'viper', 'sidewinder'],
...      columns=['max_speed', 'shield'])
>>> df
            max_speed  shield
cobra               1       2
viper               4       5
sidewinder          7       8

>>> df.loc[['viper', 'sidewinder']]
            max_speed  shield
viper               4       5
sidewinder          7       8
Posted by: Guest on March-19-2020

Code answers related to "pd.loc"

Python Answers by Framework

Browse Popular Code Answers by Language