Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

cartesian product pandas

# In recent versions of Pandas (>= 1.2) this is built into merge so you can do:
from pandas import DataFrame
df1 = DataFrame({'col1':[1,2],'col2':[3,4]})
df2 = DataFrame({'col3':[5,6]})    

df1.merge(df2, how='cross')
Comment

pandas cartesian product

a = [1, 2, 3]
b = ["a", "b", "c"]

index = pd.MultiIndex.from_product([a, b], names = ["a", "b"])

pd.DataFrame(index = index).reset_index()
Comment

PREVIOUS NEXT
Code Example
Python :: screen.onkey python 
Python :: python remove empty values from list 
Python :: np.mean 
Python :: checksum python 
Python :: make poetry env 
Python :: pandas df to dict 
Python :: pandas change period to daily frequency 
Python :: concat string columns in pandas 
Python :: How to Crack PDF Files in Python - Python Cod 
Python :: traversing a tree in python 
Python :: python save to excel 
Python :: python int16 
Python :: sendgrid send email to multiple recipients python 
Python :: next iteration python 
Python :: python dict comprehension 
Python :: read dict from text 
Python :: python check if string in string 
Python :: pytplot arc 
Python :: custom attribute selenium 
Python :: python dictonary set default 
Python :: mypy clear cache 
Python :: how to take first digit of number python 
Python :: python count how many times a character appears in a string 
Python :: all() python 
Python :: python jwt 
Python :: doomsday fuel foobar 
Python :: flask session timeout 
Python :: addition of matrix in python using numpy 
Python :: information of environment variables in python 
Python :: pandas.core.frame.DataFrame to pandas.core.series.Series 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =