Merging rows in pandas
<p>Say I have a dataframe that looks something like this</p>

<pre><code>Line   VarA        VarB
345    Something   abc
346    Something2  def
347    Something   ghi
348    Something2  jkl
349    Something   mno
350    Something2  pqr
351    Something   stu
352    Something2  vwx
</code></pre>

<p>How can I turn this dataframe into something that looks like this:</p>

<pre><code>VarA       VarB
Something  abcghimnostu
Something2 defjklpqrvwx
</code></pre>

<p>You can just <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.groupby.html" rel="nofollow">groupby</a> and <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.sum.html" rel="nofollow">sum</a></p>

<pre><code>print(df.groupby('VarA')['VarB'].sum())
VarA
something     abcghimnostu
something2    defjklpqrvwx
Name: VarB, dtype: object
</code></pre>

python pandas dataframe