text_plain_output_1.png
import pandas as pd

groceries = pd.Series(data=[20, 6, 'Yes', 'No'], index=['eggs', 'apples', 'milk', 'bread'])
groceries

print('How many eggs do we need to buy:', groceries['eggs'])
print()
print('Do we need milk and bread:\n', groceries[['milk', 'bread']])
print()
print('How many eggs and apples do we need to buy:\n', groceries.loc[['eggs', 'apples']])
print()
print('How many eggs and apples do we need to buy:\n', groceries[[0, 1]])
print()
print('Do we need bread:\n', groceries[-1])
print()
print('How many eggs do we need to buy:', groceries[0])
print()
print('Do we need milk and bread:\n', groceries.iloc[[2, 3]])