擅长:python、mysql、java
<p>只需拆分<code>|</code>上的值,然后使用前四个值获得所需的字符串,您可以使用<code>str.format()</code></p>
<pre class="lang-py prettyprint-override"><code>fString = '<thekeys db="{}" value="{}"/>\n<thekeys db={} value="{}"/>'
df['strings'].str.split('|').apply(lambda x: fString.format(x[0], x[1], x[2], x[3]))
</code></pre>
<p><strong>输出:</strong></p>
<pre class="lang-py prettyprint-override"><code>1.0 <thekeys db="gef" value="re1234"/>\n<thekeys d...
2.0 <thekeys db="tef" value="fe4545"/>\n<thekeys d...
Name: strings, dtype: object
</code></pre>