擅长:python、mysql、java
<p>你可以在这里使用<a href="https://pandas.pydata.org/docs/reference/api/pandas.Series.str.cat.html#pandas-series-str-cat" rel="nofollow noreferrer">^{<cd1>}</a></p>
<pre class="lang-py prettyprint-override"><code>df["qty"].astype(str).str.cat(
[df["things"], ("on the " + df["place"])], sep=" "
)
0 1 Apple on the Table
1 4 Mango on the Chair
2 3 Coke on the Floor
3 2 Pen on the Table
Name: qty, dtype: object
</code></pre>
<p>如果您想使用<code>f-string</code>,那么可以在轴1上使用<code>df.apply</code>(但是这种方法很慢,应该作为最后手段使用)</p>
<pre class="lang-py prettyprint-override"><code>df.apply(lambda x: f'{x.qty} {x.things} on the {x.place}', axis=1)
</code></pre>