Row-wise comparisons between two arrays Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag? The Ask Question Wizard is Live!Continuously Updating an Array (Data Fetched from an updating CSV)How to merge two dictionaries in a single expression?What is the difference between @staticmethod and @classmethod?Create ArrayList from arrayHow do I check if an array includes an object in JavaScript?How to append something to an array?PHP: Delete an element from an arrayLoop through an array in JavaScriptHow to check if an object is an array?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?
Sci-Fi book where patients in a coma ward all live in a subconscious world linked together
Seeking colloquialism for “just because”
How do I stop a creek from eroding my steep embankment?
Check which numbers satisfy the condition [A*B*C = A! + B! + C!]
How come Sam didn't become Lord of Horn Hill?
What would be the ideal power source for a cybernetic eye?
Echoing a tail command produces unexpected output?
Should I use a zero-interest credit card for a large one-time purchase?
How do pianists reach extremely loud dynamics?
Why am I getting the error "non-boolean type specified in a context where a condition is expected" for this request?
When a candle burns, why does the top of wick glow if bottom of flame is hottest?
Denied boarding although I have proper visa and documentation. To whom should I make a complaint?
How do I keep my slimes from escaping their pens?
How discoverable are IPv6 addresses and AAAA names by potential attackers?
What does F' and F" mean?
How does the particle を relate to the verb 行く in the structure「A を + B に行く」?
Using et al. for a last / senior author rather than for a first author
How to align text above triangle figure
How does debian/ubuntu knows a package has a updated version
Why is "Consequences inflicted." not a sentence?
How to react to hostile behavior from a senior developer?
How to deal with a team lead who never gives me credit?
Can I cast Passwall to drop an enemy into a 20-foot pit?
Apollo command module space walk?
Row-wise comparisons between two arrays
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?
The Ask Question Wizard is Live!Continuously Updating an Array (Data Fetched from an updating CSV)How to merge two dictionaries in a single expression?What is the difference between @staticmethod and @classmethod?Create ArrayList from arrayHow do I check if an array includes an object in JavaScript?How to append something to an array?PHP: Delete an element from an arrayLoop through an array in JavaScriptHow to check if an object is an array?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm new to Numpy and Python and I have questions. I hope you could help me.
Say, I have two arrays. Both arrays have 11 columns, with the first column being the index.
This is the example of array1. By the way, array1 would be a constantly updating array live.
[(0, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1)
(0, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1)
(0, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1)
(0, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1)
(0, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1)
(0, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1)
(0, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1)
(0, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1)
(0, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)]
I want to compare the value of the last row of array1 to all the rows of array2. (It has to be the last row of array1 because it's contents would come from a constantly updating csv file). I want to search for the closest row values between the non-label columns of the last row of array1 and all the non-label rows of array2. The label in array1 would be null and won't count in the comparison. It doesn't have to be an exact match, but I want it to locate the closest match within a set tolerance. The array2 will serve as a dictionary of sorts, with its labels serving as reference and the features in the row of those individual labels acting as the samples. Am I going about this right or is there a more appropriate way to achieve this? I intend to have 26 different types of labels representative of the 26 letters of the alphabet in array2, each with specific sets of column features. Those 26 types of labels will have 10 sample rows each. The tolerance range should be indicated by those 10 samples per label. Here is a sample of the csv data in array2 (which I could already convert into arrays).
LABEL,F1,F2,F3,F4,F5,X,Y,Z,C1,C2
1, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1
1, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1
1, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1
1, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1
1, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1
1, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1
1, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1
1, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1
1, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1
1, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1
2, 537, 504, 547, 560, 553, -92, -5132, 15972, 0, 0
2, 537, 504, 547, 559, 553, -100, -5128, 16108, 0, 0
2, 537, 504, 547, 560, 553, -124, -5088, 16092, 0, 0
2, 537, 504, 547, 559, 553, -140, -5160, 16164, 0, 0
2, 537, 504, 547, 560, 552, -112, -5320, 16072, 0, 0
2, 537, 504, 547, 560, 552, -24, -5092, 16092, 0, 0
2, 537, 504, 547, 560, 551, -148, -5104, 16108, 0, 0
2, 537, 504, 547, 560, 551, -92, -5136, 16092, 0, 0
2, 537, 504, 547, 560, 551, 4, -5032, 16076, 0, 0
2, 537, 504, 547, 560, 551, -60, -5096, 15944, 0, 0
1 is A, and 2 is B. As you can see, their only differences are the 1s and 0s in the last two columns. However, the other letters of the alphabet will have differences in multiple columns, that's why I want the last row of array1 to search for its closest match in array2.
I want to perform collective row-wise comparisons between the two arrays.
In the end, I want to print the label of array2 whose features are closest to that of the latest row of array1. And since the inputs in array1 are going to be constantly updating, if the last row of array1 would then change in values and correspond to a different label, I want it to update accordingly live as well.
Again, I'm a beginner in Python and Numpy I don't know if I'm approaching this correctly. I hope you can help me. Thank you in advance. I would really appreciate any help.
python arrays python-2.7 numpy dataframe
add a comment |
I'm new to Numpy and Python and I have questions. I hope you could help me.
Say, I have two arrays. Both arrays have 11 columns, with the first column being the index.
This is the example of array1. By the way, array1 would be a constantly updating array live.
[(0, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1)
(0, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1)
(0, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1)
(0, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1)
(0, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1)
(0, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1)
(0, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1)
(0, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1)
(0, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)]
I want to compare the value of the last row of array1 to all the rows of array2. (It has to be the last row of array1 because it's contents would come from a constantly updating csv file). I want to search for the closest row values between the non-label columns of the last row of array1 and all the non-label rows of array2. The label in array1 would be null and won't count in the comparison. It doesn't have to be an exact match, but I want it to locate the closest match within a set tolerance. The array2 will serve as a dictionary of sorts, with its labels serving as reference and the features in the row of those individual labels acting as the samples. Am I going about this right or is there a more appropriate way to achieve this? I intend to have 26 different types of labels representative of the 26 letters of the alphabet in array2, each with specific sets of column features. Those 26 types of labels will have 10 sample rows each. The tolerance range should be indicated by those 10 samples per label. Here is a sample of the csv data in array2 (which I could already convert into arrays).
LABEL,F1,F2,F3,F4,F5,X,Y,Z,C1,C2
1, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1
1, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1
1, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1
1, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1
1, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1
1, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1
1, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1
1, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1
1, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1
1, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1
2, 537, 504, 547, 560, 553, -92, -5132, 15972, 0, 0
2, 537, 504, 547, 559, 553, -100, -5128, 16108, 0, 0
2, 537, 504, 547, 560, 553, -124, -5088, 16092, 0, 0
2, 537, 504, 547, 559, 553, -140, -5160, 16164, 0, 0
2, 537, 504, 547, 560, 552, -112, -5320, 16072, 0, 0
2, 537, 504, 547, 560, 552, -24, -5092, 16092, 0, 0
2, 537, 504, 547, 560, 551, -148, -5104, 16108, 0, 0
2, 537, 504, 547, 560, 551, -92, -5136, 16092, 0, 0
2, 537, 504, 547, 560, 551, 4, -5032, 16076, 0, 0
2, 537, 504, 547, 560, 551, -60, -5096, 15944, 0, 0
1 is A, and 2 is B. As you can see, their only differences are the 1s and 0s in the last two columns. However, the other letters of the alphabet will have differences in multiple columns, that's why I want the last row of array1 to search for its closest match in array2.
I want to perform collective row-wise comparisons between the two arrays.
In the end, I want to print the label of array2 whose features are closest to that of the latest row of array1. And since the inputs in array1 are going to be constantly updating, if the last row of array1 would then change in values and correspond to a different label, I want it to update accordingly live as well.
Again, I'm a beginner in Python and Numpy I don't know if I'm approaching this correctly. I hope you can help me. Thank you in advance. I would really appreciate any help.
python arrays python-2.7 numpy dataframe
add a comment |
I'm new to Numpy and Python and I have questions. I hope you could help me.
Say, I have two arrays. Both arrays have 11 columns, with the first column being the index.
This is the example of array1. By the way, array1 would be a constantly updating array live.
[(0, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1)
(0, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1)
(0, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1)
(0, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1)
(0, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1)
(0, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1)
(0, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1)
(0, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1)
(0, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)]
I want to compare the value of the last row of array1 to all the rows of array2. (It has to be the last row of array1 because it's contents would come from a constantly updating csv file). I want to search for the closest row values between the non-label columns of the last row of array1 and all the non-label rows of array2. The label in array1 would be null and won't count in the comparison. It doesn't have to be an exact match, but I want it to locate the closest match within a set tolerance. The array2 will serve as a dictionary of sorts, with its labels serving as reference and the features in the row of those individual labels acting as the samples. Am I going about this right or is there a more appropriate way to achieve this? I intend to have 26 different types of labels representative of the 26 letters of the alphabet in array2, each with specific sets of column features. Those 26 types of labels will have 10 sample rows each. The tolerance range should be indicated by those 10 samples per label. Here is a sample of the csv data in array2 (which I could already convert into arrays).
LABEL,F1,F2,F3,F4,F5,X,Y,Z,C1,C2
1, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1
1, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1
1, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1
1, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1
1, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1
1, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1
1, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1
1, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1
1, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1
1, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1
2, 537, 504, 547, 560, 553, -92, -5132, 15972, 0, 0
2, 537, 504, 547, 559, 553, -100, -5128, 16108, 0, 0
2, 537, 504, 547, 560, 553, -124, -5088, 16092, 0, 0
2, 537, 504, 547, 559, 553, -140, -5160, 16164, 0, 0
2, 537, 504, 547, 560, 552, -112, -5320, 16072, 0, 0
2, 537, 504, 547, 560, 552, -24, -5092, 16092, 0, 0
2, 537, 504, 547, 560, 551, -148, -5104, 16108, 0, 0
2, 537, 504, 547, 560, 551, -92, -5136, 16092, 0, 0
2, 537, 504, 547, 560, 551, 4, -5032, 16076, 0, 0
2, 537, 504, 547, 560, 551, -60, -5096, 15944, 0, 0
1 is A, and 2 is B. As you can see, their only differences are the 1s and 0s in the last two columns. However, the other letters of the alphabet will have differences in multiple columns, that's why I want the last row of array1 to search for its closest match in array2.
I want to perform collective row-wise comparisons between the two arrays.
In the end, I want to print the label of array2 whose features are closest to that of the latest row of array1. And since the inputs in array1 are going to be constantly updating, if the last row of array1 would then change in values and correspond to a different label, I want it to update accordingly live as well.
Again, I'm a beginner in Python and Numpy I don't know if I'm approaching this correctly. I hope you can help me. Thank you in advance. I would really appreciate any help.
python arrays python-2.7 numpy dataframe
I'm new to Numpy and Python and I have questions. I hope you could help me.
Say, I have two arrays. Both arrays have 11 columns, with the first column being the index.
This is the example of array1. By the way, array1 would be a constantly updating array live.
[(0, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1)
(0, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1)
(0, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1)
(0, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1)
(0, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1)
(0, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1)
(0, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1)
(0, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1)
(0, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)]
I want to compare the value of the last row of array1 to all the rows of array2. (It has to be the last row of array1 because it's contents would come from a constantly updating csv file). I want to search for the closest row values between the non-label columns of the last row of array1 and all the non-label rows of array2. The label in array1 would be null and won't count in the comparison. It doesn't have to be an exact match, but I want it to locate the closest match within a set tolerance. The array2 will serve as a dictionary of sorts, with its labels serving as reference and the features in the row of those individual labels acting as the samples. Am I going about this right or is there a more appropriate way to achieve this? I intend to have 26 different types of labels representative of the 26 letters of the alphabet in array2, each with specific sets of column features. Those 26 types of labels will have 10 sample rows each. The tolerance range should be indicated by those 10 samples per label. Here is a sample of the csv data in array2 (which I could already convert into arrays).
LABEL,F1,F2,F3,F4,F5,X,Y,Z,C1,C2
1, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1
1, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1
1, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1
1, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1
1, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1
1, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1
1, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1
1, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1
1, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1
1, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1
2, 537, 504, 547, 560, 553, -92, -5132, 15972, 0, 0
2, 537, 504, 547, 559, 553, -100, -5128, 16108, 0, 0
2, 537, 504, 547, 560, 553, -124, -5088, 16092, 0, 0
2, 537, 504, 547, 559, 553, -140, -5160, 16164, 0, 0
2, 537, 504, 547, 560, 552, -112, -5320, 16072, 0, 0
2, 537, 504, 547, 560, 552, -24, -5092, 16092, 0, 0
2, 537, 504, 547, 560, 551, -148, -5104, 16108, 0, 0
2, 537, 504, 547, 560, 551, -92, -5136, 16092, 0, 0
2, 537, 504, 547, 560, 551, 4, -5032, 16076, 0, 0
2, 537, 504, 547, 560, 551, -60, -5096, 15944, 0, 0
1 is A, and 2 is B. As you can see, their only differences are the 1s and 0s in the last two columns. However, the other letters of the alphabet will have differences in multiple columns, that's why I want the last row of array1 to search for its closest match in array2.
I want to perform collective row-wise comparisons between the two arrays.
In the end, I want to print the label of array2 whose features are closest to that of the latest row of array1. And since the inputs in array1 are going to be constantly updating, if the last row of array1 would then change in values and correspond to a different label, I want it to update accordingly live as well.
Again, I'm a beginner in Python and Numpy I don't know if I'm approaching this correctly. I hope you can help me. Thank you in advance. I would really appreciate any help.
python arrays python-2.7 numpy dataframe
python arrays python-2.7 numpy dataframe
asked Mar 22 at 9:02
Tyler JosephTyler Joseph
304
304
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Your array A and B:
A = np.array([(0, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1),
(0, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1),
(0, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1),
(0, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1),
(0, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1),
(0, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1),
(0, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1),
(0, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1),
(0, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)])
B = np.array([[1, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1],
[1, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1],
[1, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1],
[1, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1],
[1, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1],
[1, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1],
[1, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1],
[1, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1],
[1, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1],
[1, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1],
[2, 537, 504, 547, 560, 553, -92, -5132, 15972, 0, 0],
[2, 537, 504, 547, 559, 553, -100, -5128, 16108, 0, 0],
[2, 537, 504, 547, 560, 553, -124, -5088, 16092, 0, 0],
[2, 537, 504, 547, 559, 553, -140, -5160, 16164, 0, 0],
[2, 537, 504, 547, 560, 552, -112, -5320, 16072, 0, 0],
[2, 537, 504, 547, 560, 552, -24, -5092, 16092, 0, 0],
[2, 537, 504, 547, 560, 551, -148, -5104, 16108, 0, 0],
[2, 537, 504, 547, 560, 551, -92, -5136, 16092, 0, 0],
[2, 537, 504, 547, 560, 551, 4, -5032, 16076, 0, 0],
[2, 537, 504, 547, 560, 551, -60, -5096, 15944, 0, 0]])
Difference between B and last row of A
D = B - A[-1]
"Closest" is always a discussion, but say you want the one where the sum of the absolute values are at a minimum.
np.abs(D).sum(axis=1).argmin()
This yields row 5 is closest.
B[np.abs(D).sum(axis=1).argmin()]
yields:
array([ 1, 537, 504, 547, 560, 552, -24, -5092, 16092,
1, 1])
Sir I tried playing with your code and they work accordingly. Thank you very much Sir! I have a follow up newbie question. How do I make my 'array A' update continuously live (as it is based on a continuously updating csv fie)? Also, that said, how do I let the output display and change based on the new inputs it will receive continuously as well?
– Tyler Joseph
Mar 22 at 10:21
These are both separate questions, that i suggest creating new Stack overflow questions for. I suggest focusing on reading the last line of the file as it is updated. You don't need to maintain an whole array, rather just the last line. For the second question, it depends entirely on how you want the update to look like. Are you thinking a command line tool or something with graphic interface.
– Christian Sloper
Mar 22 at 10:28
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55296099%2frow-wise-comparisons-between-two-arrays%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your array A and B:
A = np.array([(0, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1),
(0, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1),
(0, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1),
(0, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1),
(0, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1),
(0, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1),
(0, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1),
(0, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1),
(0, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)])
B = np.array([[1, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1],
[1, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1],
[1, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1],
[1, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1],
[1, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1],
[1, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1],
[1, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1],
[1, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1],
[1, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1],
[1, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1],
[2, 537, 504, 547, 560, 553, -92, -5132, 15972, 0, 0],
[2, 537, 504, 547, 559, 553, -100, -5128, 16108, 0, 0],
[2, 537, 504, 547, 560, 553, -124, -5088, 16092, 0, 0],
[2, 537, 504, 547, 559, 553, -140, -5160, 16164, 0, 0],
[2, 537, 504, 547, 560, 552, -112, -5320, 16072, 0, 0],
[2, 537, 504, 547, 560, 552, -24, -5092, 16092, 0, 0],
[2, 537, 504, 547, 560, 551, -148, -5104, 16108, 0, 0],
[2, 537, 504, 547, 560, 551, -92, -5136, 16092, 0, 0],
[2, 537, 504, 547, 560, 551, 4, -5032, 16076, 0, 0],
[2, 537, 504, 547, 560, 551, -60, -5096, 15944, 0, 0]])
Difference between B and last row of A
D = B - A[-1]
"Closest" is always a discussion, but say you want the one where the sum of the absolute values are at a minimum.
np.abs(D).sum(axis=1).argmin()
This yields row 5 is closest.
B[np.abs(D).sum(axis=1).argmin()]
yields:
array([ 1, 537, 504, 547, 560, 552, -24, -5092, 16092,
1, 1])
Sir I tried playing with your code and they work accordingly. Thank you very much Sir! I have a follow up newbie question. How do I make my 'array A' update continuously live (as it is based on a continuously updating csv fie)? Also, that said, how do I let the output display and change based on the new inputs it will receive continuously as well?
– Tyler Joseph
Mar 22 at 10:21
These are both separate questions, that i suggest creating new Stack overflow questions for. I suggest focusing on reading the last line of the file as it is updated. You don't need to maintain an whole array, rather just the last line. For the second question, it depends entirely on how you want the update to look like. Are you thinking a command line tool or something with graphic interface.
– Christian Sloper
Mar 22 at 10:28
add a comment |
Your array A and B:
A = np.array([(0, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1),
(0, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1),
(0, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1),
(0, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1),
(0, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1),
(0, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1),
(0, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1),
(0, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1),
(0, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)])
B = np.array([[1, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1],
[1, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1],
[1, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1],
[1, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1],
[1, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1],
[1, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1],
[1, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1],
[1, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1],
[1, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1],
[1, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1],
[2, 537, 504, 547, 560, 553, -92, -5132, 15972, 0, 0],
[2, 537, 504, 547, 559, 553, -100, -5128, 16108, 0, 0],
[2, 537, 504, 547, 560, 553, -124, -5088, 16092, 0, 0],
[2, 537, 504, 547, 559, 553, -140, -5160, 16164, 0, 0],
[2, 537, 504, 547, 560, 552, -112, -5320, 16072, 0, 0],
[2, 537, 504, 547, 560, 552, -24, -5092, 16092, 0, 0],
[2, 537, 504, 547, 560, 551, -148, -5104, 16108, 0, 0],
[2, 537, 504, 547, 560, 551, -92, -5136, 16092, 0, 0],
[2, 537, 504, 547, 560, 551, 4, -5032, 16076, 0, 0],
[2, 537, 504, 547, 560, 551, -60, -5096, 15944, 0, 0]])
Difference between B and last row of A
D = B - A[-1]
"Closest" is always a discussion, but say you want the one where the sum of the absolute values are at a minimum.
np.abs(D).sum(axis=1).argmin()
This yields row 5 is closest.
B[np.abs(D).sum(axis=1).argmin()]
yields:
array([ 1, 537, 504, 547, 560, 552, -24, -5092, 16092,
1, 1])
Sir I tried playing with your code and they work accordingly. Thank you very much Sir! I have a follow up newbie question. How do I make my 'array A' update continuously live (as it is based on a continuously updating csv fie)? Also, that said, how do I let the output display and change based on the new inputs it will receive continuously as well?
– Tyler Joseph
Mar 22 at 10:21
These are both separate questions, that i suggest creating new Stack overflow questions for. I suggest focusing on reading the last line of the file as it is updated. You don't need to maintain an whole array, rather just the last line. For the second question, it depends entirely on how you want the update to look like. Are you thinking a command line tool or something with graphic interface.
– Christian Sloper
Mar 22 at 10:28
add a comment |
Your array A and B:
A = np.array([(0, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1),
(0, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1),
(0, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1),
(0, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1),
(0, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1),
(0, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1),
(0, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1),
(0, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1),
(0, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)])
B = np.array([[1, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1],
[1, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1],
[1, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1],
[1, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1],
[1, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1],
[1, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1],
[1, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1],
[1, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1],
[1, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1],
[1, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1],
[2, 537, 504, 547, 560, 553, -92, -5132, 15972, 0, 0],
[2, 537, 504, 547, 559, 553, -100, -5128, 16108, 0, 0],
[2, 537, 504, 547, 560, 553, -124, -5088, 16092, 0, 0],
[2, 537, 504, 547, 559, 553, -140, -5160, 16164, 0, 0],
[2, 537, 504, 547, 560, 552, -112, -5320, 16072, 0, 0],
[2, 537, 504, 547, 560, 552, -24, -5092, 16092, 0, 0],
[2, 537, 504, 547, 560, 551, -148, -5104, 16108, 0, 0],
[2, 537, 504, 547, 560, 551, -92, -5136, 16092, 0, 0],
[2, 537, 504, 547, 560, 551, 4, -5032, 16076, 0, 0],
[2, 537, 504, 547, 560, 551, -60, -5096, 15944, 0, 0]])
Difference between B and last row of A
D = B - A[-1]
"Closest" is always a discussion, but say you want the one where the sum of the absolute values are at a minimum.
np.abs(D).sum(axis=1).argmin()
This yields row 5 is closest.
B[np.abs(D).sum(axis=1).argmin()]
yields:
array([ 1, 537, 504, 547, 560, 552, -24, -5092, 16092,
1, 1])
Your array A and B:
A = np.array([(0, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1),
(0, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1),
(0, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1),
(0, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1),
(0, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1),
(0, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1),
(0, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1),
(0, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1),
(0, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1),
(0, 537, 504, 547, 560, 552, -48, -5084, 16072, 1, 1)])
B = np.array([[1, 537, 504, 547, 560, 553, -92, -5132, 15972, 1, 1],
[1, 537, 504, 547, 559, 553, -100, -5128, 16108, 1, 1],
[1, 537, 504, 547, 560, 553, -124, -5088, 16092, 1, 1],
[1, 537, 504, 547, 559, 553, -140, -5160, 16164, 1, 1],
[1, 537, 504, 547, 560, 552, -112, -5320, 16072, 1, 1],
[1, 537, 504, 547, 560, 552, -24, -5092, 16092, 1, 1],
[1, 537, 504, 547, 560, 551, -148, -5104, 16108, 1, 1],
[1, 537, 504, 547, 560, 551, -92, -5136, 16092, 1, 1],
[1, 537, 504, 547, 560, 551, 4, -5032, 16076, 1, 1],
[1, 537, 504, 547, 560, 551, -60, -5096, 15944, 1, 1],
[2, 537, 504, 547, 560, 553, -92, -5132, 15972, 0, 0],
[2, 537, 504, 547, 559, 553, -100, -5128, 16108, 0, 0],
[2, 537, 504, 547, 560, 553, -124, -5088, 16092, 0, 0],
[2, 537, 504, 547, 559, 553, -140, -5160, 16164, 0, 0],
[2, 537, 504, 547, 560, 552, -112, -5320, 16072, 0, 0],
[2, 537, 504, 547, 560, 552, -24, -5092, 16092, 0, 0],
[2, 537, 504, 547, 560, 551, -148, -5104, 16108, 0, 0],
[2, 537, 504, 547, 560, 551, -92, -5136, 16092, 0, 0],
[2, 537, 504, 547, 560, 551, 4, -5032, 16076, 0, 0],
[2, 537, 504, 547, 560, 551, -60, -5096, 15944, 0, 0]])
Difference between B and last row of A
D = B - A[-1]
"Closest" is always a discussion, but say you want the one where the sum of the absolute values are at a minimum.
np.abs(D).sum(axis=1).argmin()
This yields row 5 is closest.
B[np.abs(D).sum(axis=1).argmin()]
yields:
array([ 1, 537, 504, 547, 560, 552, -24, -5092, 16092,
1, 1])
edited Mar 22 at 9:33
answered Mar 22 at 9:10
Christian SloperChristian Sloper
2,796418
2,796418
Sir I tried playing with your code and they work accordingly. Thank you very much Sir! I have a follow up newbie question. How do I make my 'array A' update continuously live (as it is based on a continuously updating csv fie)? Also, that said, how do I let the output display and change based on the new inputs it will receive continuously as well?
– Tyler Joseph
Mar 22 at 10:21
These are both separate questions, that i suggest creating new Stack overflow questions for. I suggest focusing on reading the last line of the file as it is updated. You don't need to maintain an whole array, rather just the last line. For the second question, it depends entirely on how you want the update to look like. Are you thinking a command line tool or something with graphic interface.
– Christian Sloper
Mar 22 at 10:28
add a comment |
Sir I tried playing with your code and they work accordingly. Thank you very much Sir! I have a follow up newbie question. How do I make my 'array A' update continuously live (as it is based on a continuously updating csv fie)? Also, that said, how do I let the output display and change based on the new inputs it will receive continuously as well?
– Tyler Joseph
Mar 22 at 10:21
These are both separate questions, that i suggest creating new Stack overflow questions for. I suggest focusing on reading the last line of the file as it is updated. You don't need to maintain an whole array, rather just the last line. For the second question, it depends entirely on how you want the update to look like. Are you thinking a command line tool or something with graphic interface.
– Christian Sloper
Mar 22 at 10:28
Sir I tried playing with your code and they work accordingly. Thank you very much Sir! I have a follow up newbie question. How do I make my 'array A' update continuously live (as it is based on a continuously updating csv fie)? Also, that said, how do I let the output display and change based on the new inputs it will receive continuously as well?
– Tyler Joseph
Mar 22 at 10:21
Sir I tried playing with your code and they work accordingly. Thank you very much Sir! I have a follow up newbie question. How do I make my 'array A' update continuously live (as it is based on a continuously updating csv fie)? Also, that said, how do I let the output display and change based on the new inputs it will receive continuously as well?
– Tyler Joseph
Mar 22 at 10:21
These are both separate questions, that i suggest creating new Stack overflow questions for. I suggest focusing on reading the last line of the file as it is updated. You don't need to maintain an whole array, rather just the last line. For the second question, it depends entirely on how you want the update to look like. Are you thinking a command line tool or something with graphic interface.
– Christian Sloper
Mar 22 at 10:28
These are both separate questions, that i suggest creating new Stack overflow questions for. I suggest focusing on reading the last line of the file as it is updated. You don't need to maintain an whole array, rather just the last line. For the second question, it depends entirely on how you want the update to look like. Are you thinking a command line tool or something with graphic interface.
– Christian Sloper
Mar 22 at 10:28
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55296099%2frow-wise-comparisons-between-two-arrays%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown