Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
539 B
2
Indexable
Never
import pandas as pd

states  = ['Alabama', 'Alaska', 'Arizona', 'Arkansas']
flowers = ['Camellia', 'Forget-me-not', 'Saguaro cactus blossom', 'Apple blossom']
insects = ['Monarch butterfly', 'Four-spotted skimmer dragonfly', 'Two-tailed swallowtail', 'European honey bee']
index   = ['state 1', 'state 2', 'state 3', 'state 4']

df = pd.DataFrame({'state': states, 'flower': flowers, 'insect': insects}, index=index)

print(df.loc['state 1', 'flower'], df.loc['state 1', 'insect'], df.loc['state 2', 'flower'], df.loc['state 2', 'insect'])
Leave a Comment