Python Forum
Finding and indexing maximum value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding and indexing maximum value
#1
I have a large grid, but let's say it is 4 cells wide and 3 cells high. Index of the first cell is 0 and it starts bottom left, finishes in the upper right corner with index 11.
Each cell has a value. So we have a df:

cell;value
0;8
1;2
2;1
3;6
4;4
5;6
6;7
7;1
8;2
9;5
10;3
11;5

How do I identify cell that has a max value around itself?

- For corner cells this means that we look at the observed cell and all three around it.
- For middle cells we observe the cell and all 8 around it.

The goal is to find the cell with max value, add to df a new column and to the cell with max value return 1 and all the others 0.

For the upper example this would mean:

cell;value;maxValue
0;8;1
1;2;0
2;1;0
3;6;0
4;4;0
5;6;0
6;7;1
7;1;0
8;2;0
9;5;0
10;3;0
11;5;0

EDIT:
This is the "image" of the grid and its values, respectively.

IMAGE LINK

Anyone? Should I use IF command and go with if (i+1) and (i-1) and ... ?
Reply


Messages In This Thread
Finding and indexing maximum value - by BlueBall - Oct-24-2018, 10:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Moving data from one Excel to another and finding maximum profit azizrasul 7 1,458 Oct-06-2022, 06:13 PM
Last Post: azizrasul
  How to change 0 based indexing to 1 based indexing in python..?? Ruthra 2 4,308 Jan-22-2020, 05:13 PM
Last Post: Ruthra
  Finding all maximum values in a matrix Lightning1800 3 3,803 May-14-2018, 03:55 PM
Last Post: Lightning1800

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020