Sep-24-2020, 03:13 AM
I am new to python and trying to code for the below logic but not sure how to do it using for next loop
Colum1 Colum2 col 3 Col4
1234 111 Str1 50
1234 112 Str2 -50
5677 113 Str3 110
6789 114 Str1 50
6789 114 Str2 -30
6789 114 Str3 10
1456 115 Str1 -100
1456 115 Str2 50
1456 115 Str3 40
1456 115 Str4 -10
Str1 is considered as higher and goes lower based on sequence str2, str3, str4
If the col4 is negstive it can offset where the negative number has the same or lower Str relative to the positive value
like say for col 2 - 114 and col 1 = 6789 -
If Str1 is positive then it can offset with Str 2, Str 3 or Str 4 so the revised value should be 30 for Col 1 = 6789 and Col 2= 114
Say for Col 2 = 115
Str 1 is negative but it cannot offset with Str 2 or St3 or Str 4 but Str4 can offset its negative with any other Str 2 or Str3
So there is two values for Col2 = 115 and can be separated in two columns based on sign.
a) -100
b) 80
I am not sure how to write this sequence for loop in python.
Any help would be highly appreciated.
Colum1 Colum2 col 3 Col4
1234 111 Str1 50
1234 112 Str2 -50
5677 113 Str3 110
6789 114 Str1 50
6789 114 Str2 -30
6789 114 Str3 10
1456 115 Str1 -100
1456 115 Str2 50
1456 115 Str3 40
1456 115 Str4 -10
Str1 is considered as higher and goes lower based on sequence str2, str3, str4
If the col4 is negstive it can offset where the negative number has the same or lower Str relative to the positive value
like say for col 2 - 114 and col 1 = 6789 -
If Str1 is positive then it can offset with Str 2, Str 3 or Str 4 so the revised value should be 30 for Col 1 = 6789 and Col 2= 114
Say for Col 2 = 115
Str 1 is negative but it cannot offset with Str 2 or St3 or Str 4 but Str4 can offset its negative with any other Str 2 or Str3
So there is two values for Col2 = 115 and can be separated in two columns based on sign.
a) -100
b) 80
I am not sure how to write this sequence for loop in python.
Any help would be highly appreciated.