在此,我们使用灵活的比较技术对不同的DataFrame进行比较
import pandas as pd
import random
random.seed(123)
list1 = [['A']*3,['B']*5,['C']*7]
charlist = [x for sublist in list1 for x in sublist]
random.shuffle(charlist)
ser1 = pd.Series(charlist)
random.seed(123)
ser2 = pd.Series(random.sample(range(10, 100), 15))
prodDf1 = pd.concat([ser1,ser2],axis=1)
prodDf1.columns=['Product','Sales']
random.seed(321)
list1 = [['A']*2,['B']*8,['C']*5]
charlist = [x for sublist in list1 for x in sublist]
random.shuffle(charlist)
ser3 = pd.Series(charlist)
random.seed(321)
ser4 = pd.Series(random.sample(range(10, 100), 15))
prodDf2 = pd.concat([ser3,ser4],axis=1)
prodDf2.columns=['Product','Sales']
...