Pandas DataFrames with NaNs equality comparison

In the context of unit testing some functions, I’m trying to establish the equality of 2 DataFrames using python pandas: ipdb> expect 1 2 2012-01-01 00:00:00+00:00 NaN 3 2013-05-14 12:00:00+00:00 3 NaN ipdb> df identifier 1 2 timestamp 2012-01-01 00:00:00+00:00 NaN 3 2013-05-14 12:00:00+00:00 3 NaN ipdb> df[1][0] nan ipdb> df[1][0], expect[1][0] (nan, nan) ipdb> … Read more

Comparing two string arrays in C#

Say we have 5 string arrays as such: string[] a = {“The”,”Big”, “Ant”}; string[] b = {“Big”,”Ant”,”Ran”}; string[] c = {“The”,”Big”,”Ant”}; string[] d = {“No”,”Ants”,”Here”}; string[] e = {“The”, “Big”, “Ant”, “Ran”, “Too”, “Far”}; Is there a method to compare these strings to each other without looping through them in C# such that only a … Read more

Can I use ‘ == ‘ to compare two vectors. I tried it and seems to be working fine. But I don’t know whether it will work in more complex situations

First example: int main(){ using namespace std; vector<int> v1{10, 20, 30, 40, 50}; vector<int> v2{10, 20, 30, 40, 50}; if(v1==v2) cout<<“equal”; else cout<<“unequal”; } // it returns equal Second example: int main(){ using namespace std; vector<int> v1{10, 20, 30, 40, 50}; vector<int> v2{10, 20, 100000, 40, 50}; if(v1==v2) cout<<“equal”; else cout<<“unequal”; } // it returns … Read more

How to test for (ActiveRecord) object equality

In Ruby 1.9.2 on Rails 3.0.3, I’m attempting to test for object equality between two Friend (class inherits from ActiveRecord::Base) objects. The objects are equal, but the test fails: Failure/Error: Friend.new(name: ‘Bob’).should eql(Friend.new(name: ‘Bob’)) expected #<Friend id: nil, event_id: nil, name: ‘Bob’, created_at: nil, updated_at: nil> got #<Friend id: nil, event_id: nil, name: ‘Bob’, created_at: … Read more

Comparing two List for equality

Other than stepping through the elements one by one, how do I compare two lists of strings for equality (in .NET 3.0): This fails: // Expected result. List<string> expected = new List<string>(); expected.Add( “a” ); expected.Add( “b” ); expected.Add( “c” ); // Actual result actual = new List<string>(); actual.Add( “a” ); actual.Add( “b” ); actual.Add( … Read more