I have two dataframes and I want to compare them, then display the differences side by side. I had been using the accepted solution from this question, but am now getting an error with ne_stacked = (current_df != new_df).stack()
.
This used to work fine, but the error I'm getting now is The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
. After looking at the documentation for all of these options I'm not sure how to implement any of them and keep the same functionality in my code.
How would I go about replacing ne_stacked = (current_df != new_df).stack()
so I don't get the ambiguity error?
EDIT
Basic code example as requested:
d = {'a':[1,2,3],'b':[1,2,3],'c':[1,2,3]}
d2 = {'a':[4,2,3],'b':[1,4,3],'c':[1,2,4]}
df1 = pd.DataFrame(d)
df2 = pd.DataFrame(d2)
print (df1 != df2) //returns true when value in df1 is not equal to df2
a b c
0 True False False
1 False True False
2 False False True
So the !=
expression works just fine for this simple dataframe, but not the more complex ones I'm using (below).
df1 = {'CORE': [{'satellite': '2B',
'windowEnd': '2015-218 04:00:00',
'windowStart': '2015-217 20:00:00'}],
'DURATION': [500.0],
'PRIORITY': [5],
'RATE': [u'HIGH_RATE'],
'STATUS': [u'ACTIVE'],
'TASK_ID': [1],
'TYPE': [u'NOMINAL'],
'WINDOW_END': ['2015-218 04:00:00'],
'WINDOW_START': ['2015-217 20:00:00']}
df2 = {'CORE': [{'satellite': '2B',
'windowEnd': '2015-220 04:00:00',
'windowStart': '2015-219 20:00:00'}],
'DURATION': [500.0],
'PRIORITY': [5],
'RATE': [u'HIGH_RATE'],
'STATUS': [u'ACTIVE'],
'TASK_ID': [2],
'TYPE': [u'NOMINAL'],
'WINDOW_END': ['2015-220 04:00:00'],
'WINDOW_START': ['2015-219 20:00:00']}