Computer scienceData scienceInstrumentsPandasStoring data with pandas

.loc & .iloc

Names and ages

Report a typo

What is the output of the following code?

import pandas as pd
data = {'name': ['Alice', 'Bob', 'Charlie', 'David', 'Emily'],
        'age': [25, 30, 35, 40, 45],
        'city': ['New York', 'Paris', 'London', 'Tokyo', 'Sydney']}

df = pd.DataFrame(data)
result = df.loc[df.age > 30, 'name'].tolist()
print(result)
Select one option from the list
___

Create a free account to access the full topic