Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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)
Comment

PREVIOUS NEXT
Code Example
Python :: python single line if 
Python :: Highlight Active Links in Django Website 
Python :: django run management command from code 
Python :: convert all numbers in list to string python 
Python :: installing private python packages from requirements.txt 
Python :: r named chr to dataframe 
Python :: convert nan to string pandas 
Python :: matplotlib larger chart 
Python :: optimizationed bubble sort optimizationed 
Python :: delete last message discord.py 
Python :: RuntimeError: dictionary changed size during iteration 
Python :: install apriori package python 
Python :: get unique values from a list 
Python :: python input string 
Python :: python list join array string space 
Python :: install easygui conda 
Python :: python counter nested dictionary 
Python :: python list replace nan with 0 
Python :: python reverse list 
Python :: tf.reduce_sum() 
Python :: logarithms python 
Python :: lambda and function in python 
Python :: how to install os module in python 
Python :: train_test_split from sklearn.selection 
Python :: pandas dataframe for loop begin end index 
Python :: python pandas shape 
Python :: python heatmap 
Python :: confusion matrix with labels sklearn 
Python :: console-based animation-simple 
Python :: empty list in python 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =