Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

All possible combinations of multiple columns

from itertools import product

df = pd.DataFrame({'Student':['Siri','Alexa'], 'Class':['6', '7'], 'Section':['A','B'], 'Teacher':['Ravi','Mark'], 'School':['C','D']})

uniques = [df[i].unique().tolist() for i in df.columns ]
pd.DataFrame(product(*uniques), columns = df.columns)
Comment

PREVIOUS NEXT
Code Example
Python :: lambda function in python to shut ec2 at the time zone 
Python :: django view - APIView (urls.py config) 
Python :: drop column 0 to many 
Python :: Break up long line of code to span over several lines 
Python :: qt list widget let editable 
Python :: # convert dictionary keys to a list 
Python :: cast set 
Python :: complete dates pandas per group by 
Python :: config.ini list not string 
Python :: Creating a Nested Dictionary 
Python :: raspberry pi set python 3 as default 
Python :: ccacxc 
Python :: pygame getting your charecter to jump 
Python :: print(i) 
Python :: extract data using selenium and disable javascript 
Python :: how to loop 10 times in python 
Python :: python list len 
Python :: how to seperate the script from html template when using jQuery in flask 
Python :: cours python 
Python :: Like strings (and all other built-in sequence type), lists can be indexed and sliced: 
Python :: sns.kdeplot make line more detailed 
Python :: plt datas use left and right yaxes 
Python :: Hiding and encrypting passwords in Python using advpass() module 
Python :: importing cosine from scipy 
Python :: python sort array custom comparator 
Python :: how to auto create a three dimensional array in python 
Python :: remove inner list from outer list python 
Python :: pylatex multicolumn align 
Python :: vaibhav=complex(2,5) 
Python :: max path limit python 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =