How do I concat corresponding values of two Pandas series?
<p>I have a PD DF with three columns: lon, lat, and count:</p>

<pre><code>lon    lat   count
123    456   3
789    012   4
345    678   5
</code></pre>

<p>And I'd like to concat lon and lat to make a fourth column so that the df looks like:</p>

<pre><code>lon    lat   count  text
123    456   3      '123, 456'
789    012   4      '789, 012'
345    678   5      '345, 678'
</code></pre>

<p>I tried:</p>

<pre><code>grouped['text'] = pd.Series([str(grouped['lon'])]).str.cat([str(grouped['lat'])], sep=', ')
</code></pre>

<p>But it appears to return:</p>

<pre><code>lon    lat   text
123    456   '123, 456', '345, 678', '789, 012'
789    012   
345    678
</code></pre>

<p>What am I missing here?</p>

<pre><code>df[['lon', 'lat']].astype(str).apply(lambda r: ', '.join(r), axis=1)
</code></pre>

<p>Turn your integers into strings so that you can use them in <code>join</code>, then apply the join function for each row (i.e. across each row cell thus <code>axis=1</code>)</p>

<p>Another way:</p>

<pre><code>df.astype(str).lon+', '+df.astype(str).lat  # astype optional if df already as strings
</code></pre>

python pandas pyspark concat