push-forward of linear algebraic group schemes Suppose that $\pi: X \to S$ is a proper morphism of schemes, and $G \to X$ is a flat affine algebraic group scheme over $X$. Is the push-forward $\pi_* G$ also affine? 
I'd be happy to assume more -- say that $\pi$ is smooth, and that $G$ is smooth over $X$, or even a torus...
 A: Sorry about the mistake in the comment.  First of all, for a proper, locally finitely presented morphism of schemes, $\pi:X\to S,$ with $S$ excellent (e.g., a finite type scheme over a field or over $\text{Spec}\ \mathbb{Z}$), for a finitely presented, flat, affine group scheme $\rho:G\to X$, the set-valued functor $\pi_* G$ is representable by a group scheme algebraic space that is locally finitely presented over $S$. (Ed. Thanks to @nfdc23 for pointing out that Lieblich's result only gives an algebraic space.) This follows, for instance, from Lemma 2.3.3 of the following article.
MR2233719 (2008c:14022) 
Lieblich, Max(1-PRIN) 
Remarks on the stack of coherent algebras.  
Int. Math. Res. Not. 2006, Art. ID 75273, 12 pp. 
https://arxiv.org/pdf/math/0603034.pdf
However, it is not true that $\pi_*G$ is always affine for $\pi$ a proper, locally finitely presented morphism and $G/X$ a flat, affine group scheme.
Let $S$ be $\mathbb{A}^2_k,$ the affine plane.  The open complement, $j:V\hookrightarrow \mathbb{A}^2_k,$ is a flat morphism, but it is not affine.  
Let $f:X\to S$ be the blowing up of $\mathbb{A}^2_k$ at the origin. This is a proper morphism. Denote by $E$ the exceptional divisor of $f$. Denote by $U$ the open complement of $E$.  As the complement of a Cartier divisor in a smooth scheme, the open immersion $i:U\hookrightarrow X$ is an affine morphism.  
Let $\rho:G\to X$ denote an $X$-scheme with two connected components, one of which maps isomorphically to $X$, $$\rho_e:G_e \xrightarrow{\cong} X,$$ and the second of which maps isomorphically to $U$, $$\rho_{\sigma}:G_{\sigma} \xrightarrow{\cong} U.$$  There is a unique structure of $X$-group scheme on $G$: the identity section is the inverse isomorphism of $\rho_e,$ and the multiplication morphism, $$G_\sigma\times_X G_\sigma \to G_e,$$ is the unique open immersion of $X$-schemes.  
The $X$-group scheme $G$ is flat and affine.  Yet the pushforward $\pi_*G$ is a disjoint union of a copy of $S$ and a copy of the open immersion $j:V\to S.$  This open immersion is not affine.
A: If $\pi \colon X \to S$ is proper, flat and of finite presentation and $W$ is an affine $X$-scheme, then  $\pi_*W \to S$ is affine and of finite presentation. Unless $W$ is etale over $X$, it is difficult to deduce much about the smoothness of $\pi_*W \to S$. 
To see this, you can combine an affine representability result for modules, such as https://stacks.math.columbia.edu/tag/08JY or [EGAIII-2, 7.7.8], with the ideas from Proposition 2.5 of:
Lieblich, Max, Remarks on the stack of coherent algebras, Int. Math. Res. Not. 2006, No. 11, Article ID 75273, 12 p. (2006). ZBL1108.14003.
A precise reference is Theorem 2.3 of 
Hall, Jack; Rydh, David, General Hilbert stacks and Quot schemes, Mich. Math. J. 64, No. 2, 335-347 (2015). ZBL1349.14013.1434731927. https://projecteuclid.org/euclid.mmj/1434731927
