## python – How to iterate over unique values ​​in pandas and count the frequency of associated values

I have a data frame that includes two columns of data as shown in the image below and I have added three additional columns corresponding to each of the 3 “ types '' & # 39; & # 39; & # 39; 39 ;.

My goal is: For each & # 39; ID & # 39; unique I would like to count / count the number of & # 39; types & # 39; that happen via my df and add this value to the respective column.

Using the following line, I can generate an account of each "type" value but I don't know how to iterate over each unique "ID" and then add the number of "types" to the new columns.

``````df.groupby('ID')('Type').value_counts()
``````

Thank you

## Is there an R package that can take postal codes and create a heat map of the United States by frequency of occurrence?

I want a heat card that takes the postal codes as input. From a quick search, it looks like the zip code package is out of date. Are there any other solutions?

## Excel 2013 – Doubt with grouped data – Frequency table

I wanted to know if there is a way to get a list of data in Excel if I have a frequency table, for example:

J & # 39; I

``````Dato | Frec.
1  |   3
2  |   5
3  |   2
``````

Desire

``````1
1
1
2
2
2
2
2
3
3
``````

I can't think or know anything with Excel.

## co.combinatorics – What is the frequency of whole isometries on a hypercube?

This follows this question. Right here $$m geq 3$$ is fixed and $$n to infty$$.

Consider $$v = (v_j) _ {j leq m}$$ with $$v_1, ldots, v_m in {- 1, + 1 } ^ n$$. Let:

• $$N_I (v)$$ be the number of sequences $$u_1, ldots, u_m in {- 1, + 1 } ^ n$$ isometric to $$v$$ in $$mathbb {R} ^ n$$, that is to say. $$u_j = Qv_j$$ for an orthogonal matrix $$Q$$.
• $$N_S (v)$$ be the number of sequences $$u_1, ldots, u_m in {- 1, + 1 } ^ n$$ isometric to $$v$$ in $${- 1, + 1 } ^ n$$, that is to say. $$u_j = Qv_j$$ for some people full orthogonal matrix $$Q$$.

How does the average of $$N_S (v) / N_I (v)$$ more than $$2 ^ {nm}$$ choice of sequence $$v$$ behave like $$n to infty$$. In other words, how typical are hypercube symmetries among all the isometries of finite subsets of $${- 1, + 1 } ^ n$$?

## performance – Frequency analysis for simultaneous dice rolls

My teacher told me to optimize my Perl code, but he did not say what exactly – just to simplify it.

I've changed a few things but nothing major. Am I missing something?

Perl program that allows the user to simulate simultaneously
throw of several cubes. The result of the simulation is then a total
number of points, which is the sum of the numbers of the results of the eyes
in single throw. If several of these throws are executed with more than one
cubes, the frequency distribution for the total number of eyes is
calculated. This frequency distribution must be in the console
window in the form of a table and a simple summary table.

At the beginning, the following entries must be requested by the
user:

• the number of dice that he wants to launch.
• the number of casts that he wants to perform with the number of dice selected.

The frequency distribution for the total number of eye sets must be
displayed in two different ways:

• Tabular representation in comparison with the number of points obtained and the associated frequency, the two absolute values ​​of
frequency and normalized values ​​that divide
absolute values ​​resulting from the total number of throws are
Published.
• Graphical representation as a simple bar graph (inclined 90 degrees) (for example, corresponding number of *)

Use subroutines.

``````use warnings;
use diagnostics;
use GD::Graph::hbars;
use GD;
use List::Util qw(max);
my \$number_of_dice = 0;
my \$number_of_rolls  = 0;
my \$sum_of_throw = 0;
my @total_sum_of_eyes;
my @single_sum_of_eyes;
my @frequency;
my %count;
my \$count =0;
my \$number =0;

print "n Please insert the number_of_dice: ";
chomp(\$number_of_dice=);
print "n Please instert the number_of_rolls: ";
chomp(\$number_of_rolls=);

while (\$count< \$number_of_rolls) {
roll(\$number_of_dice);
push(@total_sum_of_eyes,\$sum_of_throw);
\$count++;
}
frequency();
representation ();

sub roll{
\$sum_of_throw = 0;
for(\$i = 0; \$i< \$number_of_dice; \$i++)
{
\$number = int(rand(6) +1);
\$sum_of_throw+=\$number;
}
}

sub frequency{
foreach my \$eyes(sort{\$a <=> \$b} @total_sum_of_eyes){
\$count{\$eyes}++;
}
}
sub representation{
#Tabular representation
print "n the frequencys-distribution is: n";
print "n total_sum_of_eyest frequencyt frequencys-distribution in %n";
foreach my \$eyes (sort{\$a <=> \$b} keys %count){
push(@frequency, \$count{\$eyes});                #data for the bar chart
push(@single_sum_of_eyes, \$eyes);               #data for the bar chart
printf "nt \$eyesttt  \$count{\$eyes}tt%g",(\$count{\$eyes}/\$number_of_rolls)*100;
}
print "n";
#bar chart
my \$graph = GD::Graph::hbars->new(1600, 600);
\$graph->set(
x_label             => 'total_sum_of_eyes',
y_label             => 'frequency',
title               => 'frequencys-distribution',
y_max_value         =>  max(@frequency)+1,
y_min_value         =>  0,
y_tick_number       => 8,
transparent         => 0,
bgclr               => 'white',
long_ticks          => 1,
) or die \$graph->error;
my @data = (@single_sum_of_eyes,@frequency);
\$graph->set( dclrs => ( qw(green) ) );
my \$gd = \$graph->plot(@data) or die \$graph->error;
open(IMG, '>gd_bars.gif') or die \$!;
binmode IMG;
print IMG \$gd->gif;
}

``````

## Reverse Proxy – How to Set TCP for High Frequency Connections Between Two Nodes

I have been scratching my head for a few days, trying to find a solution to the next problem we are facing.

In our data center, we have an F5 running on BigIP hardware that serves as a single point of entry for HTTPS requests from client computers in our various offices across the country. F5 terminates TLS and then passes all requests to two Traefik load balancers, which route them to the different service instances (Traefik nodes run in Docker under Red Hat Enterprise, but I do not think that this n & # 39; Does not affect my problem). From the point of view of throughput, processor and memory, these three network components are more than capable of managing the number of requests and the traffic with a considerable capacity to save.

However, we found frequent delays of 1000 ms in client HTTP (S) requests, especially during periods of high load. We followed the problem to the following root cause:

• During periods of high load, the "client" F5 establishes new TCP connections with Traefik's "server" nodes at a high frequency (possibly more than 100 per second).
• These connections are terminated on the server side of Traefik when HTTP responses have been returned.
• Each closed connection remains in the TIME_WAIT state for 60 seconds on the Traefik host.
• When the F5 establishes a new connection, it randomly chooses an available port in its ephemeral port range.
• Sometimes (often during a high load), there is already a connection in Traefik in the TIME_WAIT state with the same source + IP, destination + IP combination. When this occurs, the TCP stack (?) On the Traefik host ignores the first SYN packet. Note: RFC 6056 calls this collision of instance identifiers.
• After 1000 ms, the retransmission delay mechanism (RTO) goes into action on the F5 and returns the SYN packet. This time, the Traefik host accepts the connection and completes the request correctly.

Obviously, these delays of 1000 ms are absolutely unacceptable. We have therefore considered the following solutions up to now:

1. Reduce the RTO in F5 to retransmit faster, eg. at 200ms.
2. Minimize net.ipv4.tcp_fin_timeout to close TIME_WAIT connections faster.
3. Enable net.ipv4.tcp_tw_reuse: Not needed for incoming connections.
4. Enable net.ipv4.tcp_tw_recycle: AFAIK is contraindicated if the client sends random TCP timestamps. Conflicting information (including empirical evidence) indicating whether this feature has been removed from Linux or not. In addition, it is generally recommended NOT to spoil.
5. Add more IP sources and / or have Traefik listen on multiple ports to increase the number of permutations in IP / port tuples.

I'm going to throw # 1 because it's just a band-aid. Delays still occur, just a little less noticeable. No. 3 would have no effect, No. 4 would probably make the system non-functional. This leaves the n ° 2 and n ° 5.

But based on what I've learned after reading dozens of posts and technical articles, the two will only end up by reduce the chance of these "collisions". Because, which ultimately prevents the sender, F5, from randomly choosing (pseudo) a combination of ephemeral port, source address, and target port that still exists in the TIME_WAIT state on the targeted Traefik host, whatever the brevity of the end_timeout parameter should stay in the range of several seconds anyway)? We would only want to reduce the risk of collision, not eliminate it.

After all my research and at the time of gigantic Web applications, it really surprises me that this problem is not further discussed on the Web (and available solutions). I would really appreciate your thoughts and ideas to find out if there is a better and more systematic solution on PCT lands that will lead to the occurrence of nearly zero collisions. I'm thinking of a TCP configuration that will allow the Traefik host to immediately accept a new connection, even if an old connection was in the TIME_WAIT state. But from now on, no chance to find that.

Random thoughts and points:

• At this point, it is not possible to modify our various internal applications to use longer running HTTP (S) connections to reduce the number of requests / connections per second.
• The network architecture of F5 and Traefik is not to discuss, it can not be changed.
• I have recently studied the selection of ephemeral ports on Windows clients. This algorithm seems to be sequential, not random. Maximizes the time needed for the port to be reused and reduces security.
• When testing load on an otherwise idle system, we generated about 100 HTTP requests / connections per second. The first collisions have already occurred after a few seconds (say before the total of 2000 requests), even though the F5 is configured to use more than 60,000 ephemeral ports. I guess this is due to the pseudo-random nature of the port selection algorithm, which seems to do a pretty mediocre job to avoid instance-id collisions.
• The fact that the Traefik host accepts the TCP connection when retransmitting SYN packets is probably a problem. functionality of the TCP implementation. RFC6056 talks about Assassination TIME_WAIT, which could be related to that.

## What is the proper frequency for defining reverification links on a project?

What is the correct frequency to set to check links again on a project?
Currently, I do not double check. I've changed that some time ago to be so, and I was doing all this manually via the menu led by Recheck. I have too many individual projects now to do it. It was a bad idea!
Sooooo..I have not checked again for a while. So, I build links to nowhere. Waste of resources and time.
What are the considerations for the time interval I choose?
There should not be a single "best answer", I would say, if it is possible for the user to change this setting.
Nothing in this SER software is a lost feature, I realize …

## What is the frequency of outsourced support – and is there a way to know that an hosting provider uses it?

I attended 1and1.com today, with whom I registered an unusual TLD last year, as it was the first company I found. to offer it.

Thinking that the name of my "support specialist" looked like a kind of phishing, so we decided to run it via Google.

Here is what I found:

\$4/hour outsourced support at 1and1.com

Thought was pretty crazy.

1 & 1 is positioned as "the largest web host in Europe" … and they literally pay \$ 4 / hour in the Philippines to manage their service desk?

Is this a common practice in the industry?

Maybe there is a list of companies that outsource their support to low pay bases that I can avoid?

I can understand why companies are tempted to reduce the cost of their helpdesk teams.

But hiring Upwork freelancers at \$ 4 at the time seems to me to be very unprofessional.