import pandas as pd
sales1 = [{'account': 'Jones LLC', 'Jan': 150, 'Feb': 200, 'Mar': 140},
{'account': 'Alpha Co', 'Jan': 200, 'Feb': 210, 'Mar': 215},
{'account': 'Blue Inc', 'Jan': 50, 'Feb': 90, 'Mar': 95 }]
sales2 = [{'account': 'Jones LLC', 'Jan': 150, 'Feb': 200, 'Mar': 140},
{'account': 'A', 'Jan': 200, 'Feb': 210, 'Mar': 215},
{'account': 'S', 'Jan': 50, 'Feb': 90, 'Mar': 95 }]
df1 = pd.DataFrame(sales1)
df2 = pd.DataFrame(sales2)
def CheckDF(df1,df2):
for (item, Value),(item1, Value1) in
zip(df1['account'].iteritems(),df2['account'].iteritems()):
if len(str(Value).strip()) == len(str(Value1).strip()):
print(True)
else:
print(False)
CheckDF(df1,df2)
DF1:
Feb Jan Mar account
0 200 150 140 Jones LLC
1 210 200 215 Alpha Co
2 90 50 95 Blue Inc
DF2:
Feb Jan Mar account
0 200 150 140 Jones LLC
1 210 200 215 A
2 90 50 95 S
Выход:
True
False
False