擅长:python、mysql、java
<p>使用<code>str.endswith()</code></p>
<p><strong>Ex:</strong></p>
<pre><code>df = pd.DataFrame({"Col1": ['016e3d588c', '071b4x718g', '011e3d598c', '041e0i608g']})
df["Col2"] = df["Col1"].str.endswith("g").astype(int)
print(df)
</code></pre>
<p><strong>输出:</strong></p>
<pre><code> Col1 Col2
0 016e3d588c 0
1 071b4x718g 1
2 011e3d598c 0
3 041e0i608g 1
</code></pre>