python – Indexing values ​​from a file

I'm desperately trying to get a job off the job, and I just can not figure it out.
Short description:
I need to monitor a file that generates some values. I can isolate the values ​​in a separate file, and I'm a string to assign an index to each value.

Description:

My specified file (file A) will look like this, but with more than 10000 entries:

402
506
223
123
5667
17430
9921
9232

All the values ​​in it are basically integers ranging between 103 and 17431. For every single number from File A, I have to assign an index value from 0 to 9.
My first approach was to use sed This will replace any string from file A with the specified value of the given index, but it takes too long for my large file.
Another approach that was recommended to me was to use awk but I fail too. My script looked like this:

awk '($0>=363 && $0<=499) || ($0>=4645 && $0<=4646) {$0="0"}1' tmp >tmp2

awk '($0>=2174 && $0<=2193)  {$0="1"}1' tmp >tmp2

awk '($0==500) || ($0>=12308 && $0<=12356) {$0="2"}1' tmp >tmp2

awk '($0>=103 && $0<=220) || ($0>=252 && $0<=299) || ($0>=1980 && $0<=1986) || ($0>=2921 && $0<=2922) {$0="3"}1' tmp >priority

awk '($0>=221 && $0<=251) || ($0>=8085 && $0<=8091) || ($0==8350) || ($0>=12809 && $0<=12945) || ($0>=16834 && $0<=17033)  {$0="4"}1' tmp >tmp2

awk '($0>=300 && $0<=362) || ($0=522) || ($0>=2923 && $0<=2925) || ($0>=3441 && $0<=3442) || ($0=4644)|| ($0>=5677 && $0<=5695) || ($0>=8082 && $0<=8083)|| ($0>=8093 && $0<=8349) || ($0>=12946 && $0<=12947) || ($0>=21986 && $0<=13215) || ($0>=13309 && $0<=13311)  {$0="5"}1' tmp >tmp2

I had hoped for an issue like:

5
3
3
2
1
6
7
7

Does not happen. I declare the ranges for each index and try to replace each value accordingly, but it does not work. Im trying to take afor loopor anotherwiseapproach but i do not know how just because II'm new to this.
If someone can help me with a syntax that helps me?
I tried to write something similar with:

x=value from file list.csv
for x in rage1 or range2 or range3 
 replace x with 0
for x in range 3 or range 4 or range 5
 replace x with 1

OR an if/else approach

x=values from list.csv
if x in range1 or range2 or range3 
  then replace x with 0
else if x in range4 range5 range6
  then replace x with 1

Can somebody help me with it? I'm trying to make it as good as possible (Bash, Pearl, Python …) so any idea is welcome as long as it's explained a bit how to say I'm new to it. Many thanks.

Worksheet Function – You need an Excel formula that subtracts the most recent from 5 values ​​in a column from the oldest

I am a strength and conditioning coach and need assistance in breaking down my athletes' scores. I need help writing a formula that subtracts the oldest of 5 test scores from the latest. The hand has almost 3000 rows, with each athlete having 5 rows (semesters 1, 2, 3, 4 and summer), regardless of their actual participation in these tests. So the formula has to go through the column and take the first available value out of the 5 cells and subtract it from the last available value in the 5 cells. The sheet is structured as follows:

Please help! I'm sorry if that does not give enough information, I'm new to the site.

Find values ​​of $ k $, $ l $ and $ m $ so that the following equation is true

I'm trying to find the (numerical) subset of $ (k, l, m) in (- pi, pi) times (- pi, pi) times (- pi, pi) $
where the next expression is valid
$$
tan Bigl (
frac {k + l + m} {2}
Bigr)
=
frac { sin k + sin l + sin m} { cos k + cos l + cos m}.
$$

If I fix it $ k $ I am able to ContourPlotto
Get a series of curves that show where the previous one
Expression is satisfied. However, I do not want to get one
Curve but the values ​​of $ l $ and $ m $,

Note that with NSolve "This system can not be solved
to solve with the methods available. ". NMinimize only gives
a point on the curve.

Complex residue with absolute values

To let $ a, b in mathbb {C} $With $ | b | <1 $, Calculate the integral
$$ frac {1} {2 pi} int_ {| z | = 1} frac {| z-a | ^ 2} {| z-b | ^ 2} frac {dz} {z}. $$

I know that $$ frac {1} {2 pi} int_ {| z | = 1} frac {| za | ^ 2} {(eg) ( bar {z} – bar {b})} frac {dz} {z} $$
This has a remainder of order 1 at $ z = b $ and at $ z = 0 $,

Question 1: My professor said that because $ z bar {z} = 1 $. $ frac {1} {z} = bar {b} $ so $ z = frac {1} { bar {b}} $But does that not limit our solutions to the limit? Would not we want to know what's going on $ bar {z} – bar {b} = 0 $ regardless of whether $ z bar {z} = 1 $ or no? Why do we make that assumption?

Question 2: Okay, say goodbye, I accept the above and continue with the problem. then I can accept that $ frac {1} { bar {b}}> 1 $ and thus outside our contour.

For a singularity of order $ n $:
Res {Res {$ f, z_0 $} $ = frac {1} {(n-1)!} lim_ {z rightarrow z_0} frac {d ^ n} {dz ^ n} big ((z-z_0) ^ nf (z) big ) $, I also know that if $ phi (z_0) neq 0 $ and $ z_0 $ is a singularity of order $ n $ then there is{$ frac { phi (z)} {g (z)}, z_0 $} $ = $ $ frac { phi (z_0)} {g & # 39; (z_0)} $

Res {Res {$ f, b $} $ = lim_ {z rightarrow b} frac {| z-a | ^ 2} {z ( bar {z} – bar {b})} $ but then that does not diverge? If I use this practical trick (again not sure why we can use it, does not it limit our answer?), Then Res {$ f, b $} $ = lim_ {z rightarrow b} frac {| za | ^ 2} {z (z- frac {1} { bar {b}})} = frac {| ba | ^ 2} {b (b- frac {1} { bar {b}})} $ ,

Res {Res {$ f, 0 $} $ = frac {| z-a | ^ 2} {| z-b | ^ 2} = frac {| a | ^ 2} {| b | ^ 2} $

$$ frac {1} {2 pi} int_ {| z | = 1} frac {| za | ^ 2} {| eg | ^ 2} frac {dz} {z} = text {res} {f, b } + text {res} {f, 0 } = frac {| a | ^ 2} {| b | ^ 2} + frac {| ba | ^ 2} {b (b- frac {1} { bar {b}})}. $$

Do I have to do a special case for …? $ b = 0? $
$$ frac {1} {2 pi} int_ {| z | = 1} frac {| za | ^ 2} {| z | ^ 2} frac {dz} {z} = frac {1} {2 pi i} int_ {| z | = 1} frac {| za | ^ 2} {z ^ 2 bar {z}} dz $$

Poles of order 3?

$$ text {res} {f, 0 } = lim_ {z rightarrow 0} frac {d ^ 2} {dz ^ 2} z frac {| za | ^ 2} { bar {z}} $$
and now I'm stuck.

In another point, I know

$$ frac {n!} {2 pi} int_C frac {f (z)} {(za) ^ {n + 1}} dz = f ^ {(n)} (a) text {and } frac {1} {2 pi i} int_C frac {f (z)} {(za)} dz = f (a) $$

So I have (that must be wrong, because I disregard the absolute sign)
$$ f ^ 1 (b) = frac {1!} {2 pi} int_C frac { frac {| za | ^ 2} {z}} {| eg | ^ 2} = frac {1} {2 pi i} frac {| ba | ^ 2} {b} $$
and
$$ f (0) = frac {1} {2 pi} int_C frac { frac {| za | ^ 2} {| eg | ^ 2}} {z} dz = frac {2 pi i | a | ^ 2} {| b | ^ 2} $$

Identify many types of values

I have a function that gets a token and validates it with JwtSecurityTokenHandler,
I extract the values ​​like:

    var jwtToken = tokenHandler.ReadToken(decryptTokenString) as JwtSecurityToken;
    var ifExpiredToken = jwtToken.Claims.First(claim => claim.Type == "expiredDate").Value;
    var actionName = jwtToken.Claims.First(claim => claim.Type == "actionName").Value;
    var fieldName = jwtToken.Claims.First(claim => claim.Type == "fieldName").Value;
    var memberId = jwtToken.Claims.First(claim => claim.Type == "memberId").Value;
    var value = jwtToken.Claims.First(claim => claim.Type == "value").Value;
    DateTime dateExpiredToken = DateTime.ParseExact(ifExpiredToken, "ddMMyyyy", CultureInfo.InvariantCulture);

Do I have a better way?

unity – GetPixel () does not return the values ​​correctly

So I'm trying to use the GetPixel () function to find out which colors represent the texture as the value of x and y. So far it works fine, but only 1 color is returned since the rest of the colors of the copied texture can not be preserved.
Example texture
Let's look at this texture, mine is pretty similar. I will update it as soon as I can. But it will work as an example, basically, GetPixel () returns only the red value, while the rest does not exist at all. I leave the code here:

public Color color1;
public Color color2;
public Texture2D oldTexture;

public Texture2D GetTexture(){
   var texture = new Texture2D(width, height);
   var pixels = new Color(width * height);

   for(var x = 0; x < width; x++){
      for(var y = 0; y < height; y++){
         Color newPixels = oldTexture.GetPixel(x, y);

         if(newPixels == color1){
            pixels(x + y * width) = Color.red;
         }
         else if (newPixels == color2){
            pixels(x + y * width) = Color.blue;
         }
         else{
            pixels(x + y * width) = Color.white;
         }
      }
   }

   texture.SetPixels(pixels);
   texture.Apply();

   return texture;
}

What I'm trying is, whenever this texture is "color1", set the new texture as red color to the specified x and y coordinates, then check again and set the texture "color2" in the x and y messages is too blue and so on.
However, this only returns color1 for the correct x, y coordinates and then jumps to the else function as if color2 never existed in the old texture.
By the way, since this is an example, oldTexture is generated procedurally, but the colors are set in the inspector. So I'm just taking the color I've specified, but I do not know why it basically just returns one of many colors. It checks for all the colors.
Do I miss something or do I not understand the function GetPixel () and how does it work? Every help is appreciated!

pandas – How to fill in the missing values ​​of a column in which both the first and the last value are missing?

I've tried to fill the missing values ​​with bfill / ffill when using ffill, the first line is missing and when i use bfill, the last values ​​are missing. How can I fill all missing values ​​with bfill / ffill?
thank you in advance

pd.DataFrame((('Eagle River','NaN','light'),
         ('Ybor','Red','oval'),
          ('Holyoke','blue','oval'),
         ('Abilene','NaN','disk')),columns=('City','Colors','Shape'))