Answers for "how to select certain rows in data python"

2

select specific rows from dataframe in python

select_color = df.loc[df['Color'] == 'Green']
Posted by: Guest on December-03-2020
0

select rows in python

import pandas as pd

boxes = {'Color': ['Green','Green','Green','Blue','Blue','Red','Red','Red'],
         'Shape': ['Rectangle','Rectangle','Square','Rectangle','Square','Square','Square','Rectangle'],
         'Price': [10,15,5,5,10,15,15,5]
        }

df = pd.DataFrame(boxes, columns= ['Color','Shape','Price'])

color_and_shape = df.loc[(df['Color'] == 'Green') & (df['Shape'] == 'Rectangle')]
print (color_and_shape)
Posted by: Guest on August-30-2021

Code answers related to "how to select certain rows in data python"

Python Answers by Framework

Browse Popular Code Answers by Language