How to calculate the mean from bin endpoints and frequencies? Sometimes data extracted from reports do not have individual values, like 4, 23, 43, but grouped together like this:




income level
people in this group




10k to 20k
44


20k to 40k
240


40k to 80k
400


80k to 100k
130




What is the best way to describe this situation in statistics, and how to calculate the mean value?
At first, I thought about multiplying the mid value of the first row by the number of people, i.e.:
mean = ((15k x 44) + (30k x 240) + (60k x 400) + (90k * 130))/(44 + 240 + 400 + 130)
However, I feel since the distribution is skewed, the mid point doesn't represent the mean value in each group, and thus the calculation above is wrong.
I also thought about using weighted arithmetic mean, but I am not sure.
What is the statistic tool to deal with this sort of problem?

Because your data is binned into intervals, you cannot really calculate the original sample mean because you should not make up information that you don't have access to. However, you have a couple of options.
Option 1
Your first option, which is the one many people take, is to calculate the mean based on the midpoints. This approach is an estimation subject to binning error. This is what you've done in your original post.
Option 2
Your second option is my preferred option, which is calculate an interval that the mean sits within. This can be done with the use of interval arithmetic. It has the following rules for $x_1,x_2,y_1,y_2 \in \mathbb{R}$:
$$[x_1, x_2] + [y_1, y_2] = [x_1 + y_1, x_2 + y_2]$$
$$[x_1, x_2] - [y_1, y_2] = [x_1 - y_1, x_2 - y_2]$$
$$[x_1, x_2] \cdot [y_1, y_2] = [\min \{x_1 y_1, x_1y_2,x_2y_1, x_2y_2 \}, \max \{x_1 y_1, x_1y_2,x_2y_1, x_2y_2 \}]$$
$$\frac{[x_1, x_2]}{[y_1, y_2]} = [x_1, x_2] \cdot \frac{1}{[y_1, y_2]}$$
where
$$\frac{1}{[y_1, y_2]} = \begin{cases} 
      \left[\frac{1}{y_2}, \frac{1}{y_1}\right] & 0 \not\in [y_1,y_2] \\
      \left(-\infty, \frac{1}{y_1}\right] & y_1 \neq 0 \land y_2 = 0 \\
      \left[\frac{1}{y_2},\infty\right) & y_1 = 0 \land y_2 \neq 0 \\
       \left(-\infty, \frac{1}{y_1}\right] \cup \left[\frac{1}{y_2},\infty\right) & 0 \in (y_1, y_2)
   \end{cases}$$
Note that for the above rules a constant $\alpha \in \mathbb{R}$ can be thought of as the interval $[\alpha, \alpha]$ for the purposes of combining intervals with scalars.
In your case, the following can be done quickly in the Python interpreter.
Python 3.6.9
>>> import numpy as np
>>> intervals =[[10,20], [20,40], [40, 80], [80,100]]
>>> weights = [44, 240, 400, 130]
>>> result = 0
>>> for i,j in zip(intervals, weights):
...     result += np.array(i) * j
...
>>> result / np.sum(weights)
array([38.86977887, 68.15724816])

Thus the mean income sits somewhere within \$$[38869.78, 68157.25]$.
