I'm working on a function $\zeta(\xi)$ that takes as input an integer $\xi$ (in base $10$) and calculates how many $1$'s there are in its binary representation. How can I write such function?
Here is a graph of $\zeta(\xi)$, for $0\leq\xi\leq250$, created in Excel:
By now, I have tried only brute-forcing: calculate a lot of values of $\zeta(\xi)$ to try to find a common pattern, but this doesn't seem helpful in finding an explicit formula. Any idea?

Here you go: $$ f(n) = \begin{cases} 0 & n = 0 \\ 1 & n = 1 \\ n \bmod 2 + f(\lfloor \frac{n}{2} \rfloor) & \text{else} \end{cases} $$
This exactly matches @ViktorGlombik's observation in the comments (no surprise!) If you prefer, there's $$ f(n) = \sum_{i = 0}^n \left( \lfloor\frac{n}{2^i}\rfloor \right) \bmod 2. $$
And if you don't like the use of $k \bmod 2$, you can replace it by $k - 2\lfloor\frac{k}{2}\rfloor$ (which works for nonnegative $k$ at least, which appears to be what you care about).
And if you don't like the use of "floor", you can replace it by $$ \lfloor x \rfloor = x - \frac12 + \frac{1}{\pi} \sum_{k=1}^\infty \frac{\sin (2 \pi k x)}{k}. $$
But honestly --- all that work to express as a double-sum a thing for which you've already got a working program? It's hard to see the value here. If you want to do it, go for it.