Summing over General Functions of Primes and an Application to Prime $\zeta$ Function Along the lines of thought given here, is it in general possible to substitute a summation over a function $f$ of primes like the following:
$$
\sum_{p\le x}f(p)=\int_2^x f(t) d(\pi(t))\tag{1}
$$
and further
$$
\int_2^x f(t) d(\pi(t))=f(t)\pi(t)\biggr|_2^{x}-\int_2^{x}f'(t)\pi(t)dt\tag{2}.
$$

If it's possible only for some cases, how can one specify them? answered in the comments

Let's continue from $(2)$ with an representation of the prime counting function:
$$
\pi(t) = \operatorname{R}(t^1) - \sum_{\rho}\operatorname{R}(t^{\rho}) \tag{3}
$$
with $    \operatorname{R}(u) = \sum_{n=1}^{\infty} \frac{ \mu (n)}{n} \operatorname{li}(u^{1/n})$ (the so-called Riemann's ${\rm R}$ Function, see e.g. $(11)$ here) and $\rho$ running over all the zeros (trivial and non-trivial) of $\zeta$ function. $\operatorname{li}(\cdot)$ is the logarithmic integral.
So we have 
$$
\begin{eqnarray}
&=&f(t)\pi(t)\biggr|_2^{x}-\int_2^{x}f'(t)\pi(t)dt\\
&=&f(t)\left(\operatorname{R}(t^1) - \sum_{\rho}\operatorname{R}(t^{\rho})\right)\biggr|_2^{x}
-\int_2^{x}f'(t)\left(\operatorname{R}(t^1) - \sum_{\rho}\operatorname{R}(t^{\rho})\right)dt \phantom{somemorerspace}\\
&\phantom{AA}&\\
&=&\sum_{n=1}^{\infty}\frac{ \mu (n)}{n}\Big\{\left[f(t)\left( \sum_{z\in\{1,\rho\}} (-1)^{1-\delta_{1z}} \operatorname{li}(t^{z/n})\right)\right]_2^{x}\\
&&- \int_2^{x}f'(t)\left( \sum_{z\in\{1,\rho\}} (-1)^{1-\delta_{1z}} \operatorname{li}(t^{z/n})\right)dt\Big\}\\
&\phantom{AA}&\\
&=&\sum_{n=1}^{\infty}\frac{ \mu (n)}{n}\sum_{z\in\{1,\rho\}}(-1)^{1-\delta_{1z}}\left\{\left[f(t)\left(   \operatorname{li}(t^{z/n})\right)\right]_2^{x} -
\int_2^{x}f'(t)\left(  \operatorname{li}(t^{z/n})\right)dt\right\}\hskip0.9in(4)
\end{eqnarray}
$$
where I tried to combine the sum a little without introducing to much confusion by using 
$$
(-1)^{1-\delta_{1z}}=
\cases{
+1&$ \text{if } z=1$\\
-1&$ \text{if } z=\rho$\\
}
$$
Now, what if we just take an approximation $\tilde{\pi}(t)$, where the sums over $n$ and $\rho$ are truncated. Is this approach still valid? I'm worried because $\tilde{\pi}(t)$ might not be monotone, which is a prerequisite of the Lebesgue-Stieltjes integration. 
Let's work out the last integral, by parts:
We use
$$
\int_2^{x}f'(t) \operatorname{li}(t^{w})dt
=\left[ f(t)\operatorname{li}(t^{w}) \right]_2^x - \int_2^x \frac{f(t)wt^{w-1}}{\ln(t^w)}dt
\tag{5}
$$
which gives a nice result when $f(t)=t^{-s}$, see here:
$$
\int_2^{x}(-st^{-s-1}) \operatorname{li}(t^{w})dt
=\left[ t^{-s}\operatorname{li}(t^{w}) \right]_2^x - \int_2^x \frac{t^{-s}t^{w-1}}{\ln(t)}dt
=\left[ t^{-s}\operatorname{li}(t^{w}) \right]_2^x - \left[{\rm li}(t^{w-s})\right]^x_2.
$$
So overall we get
$$
\sum_{n=1}^{\infty}\frac{ \mu (n)}{n}\sum_{z\in\{1,\rho\}}(-1)^{1-\delta_{1z}}\left\{\left[f(t)  \operatorname{li}(t^{z/n})\right]_2^{x}-
\left[ f(t)\operatorname{li}(t^{z/n}) \right]_2^x +\int_2^x \frac{zf(t)t^{z/n-1}}{n\ln(t^{z/n})}dt \right\}\\
=\sum_{n=1}^{\infty}\frac{ \mu (n)}{n}\sum_{z\in\{1,\rho\}}(-1)^{1-\delta_{1z}}\left\{\int_2^x \frac{f(t)t^{z/n-1}}{\ln(t)}dt \right\}\tag{6}\\
$$
and in the special case $f(t)=t^{-s}$ this simplifies to
$$
P_\color{red}x(\color{blue}s)=\sum_{p<\color{red}x} \frac{1}{p^s} =\sum_{n=1}^{\infty}\frac{ \mu (n)}{n}\sum_{z\in\{1,\rho\}}(-1)^{1-\delta_{1z}}
\left[
{\rm li}(t^{\frac zn-\color{blue}s})
\right]^{\color{red}x}_2
\tag{7}
$$
(for the interested reader: the story continues here...)
If anybody could confirm this, it would be ever so cool.
Thanks for your help and your time for reading all this,  
 A: If your function $f$ is smooth and compactly supported then the formula you are looking for already exists, and is called the "explicit formula". See for example Lemma 1 in http://arxiv.org/abs/math/0511092. 
If you want to apply this lemma in the direction "primes to zeros" then you should "swap the hats" over $h$. Basically, once you have specified $\hat{h}$ to be a smooth compact function of your choice, the resulting function $h$ will be entire and you will be able to apply the lemma 1 to $h$, getting the desired formula a sum over the primes weighted by $\hat{h}$. 
A: An effective form of the Riemann explicit formula is
$$\psi(n+1/2) =\sum_{p^k \le n+1/2} \log p = n+1/2-  \sum_{|\Im(\rho)| < T} \frac{(n+1/2)^\rho}{\rho}-\log 2\pi + \mathcal{O}(\frac{n \log n}{T})$$
(where $n+1/2$ is for avoiding the Gibbs phenomenom at integer values)
Thus
$$\sum_{p^k \le N} f(p^k) \log p = \sum_{n = 1}^N f(n) (1-  \sum_{|\Im(\rho)| < T} \frac{(n+1/2)^\rho-(n-1/2)^\rho}{\rho}) + \mathcal{O}(\sum_{n=1}^N |f(n)|\frac{n \log n}{T})$$
The same idea can be adapted to explicit formulas for $J(x) = \sum_{p^k \le x} \frac{1}{k}$ and $\pi(x) = \sum_{p \le x } 1 = \sum_{m=1}^x \frac{\mu(m)}{m} J(x^{1/m})$
Summing by parts you'll improve the error term to $\mathcal{O}( |f(N)|\frac{N \log N}{T})+\mathcal{O}(\sum_{n=1}^N |f(n)-f(n+1)|\frac{n \log n}{T})$
