1from pandas import DataFrame
2
3boxes = {'Color': ['Green','Green','Green','Blue','Blue','Red','Red','Red'],
4 'Shape': ['Rectangle','Rectangle','Square','Rectangle','Square','Square','Square','Rectangle'],
5 'Price': [10,15,5,5,10,15,15,5]
6 }
7
8df = DataFrame(boxes, columns= ['Color','Shape','Price'])
9
10select_color = df.loc[df['Color'] == 'Green']
11print (select_color)
12
1import pandas as pd
2
3boxes = {'Color': ['Green','Green','Green','Blue','Blue','Red','Red','Red'],
4 'Shape': ['Rectangle','Rectangle','Square','Rectangle','Square','Square','Square','Rectangle'],
5 'Price': [10,15,5,5,10,15,15,5]
6 }
7
8df = pd.DataFrame(boxes, columns= ['Color','Shape','Price'])
9
10color_and_shape = df.loc[(df['Color'] == 'Green') & (df['Shape'] == 'Rectangle')]
11print (color_and_shape)
12