bdoe85:
df=pd.DataFrame({'col1':[25021,25002,8002,40211,2232,""]})
col1
0 25021
1 25002
2 8002
3 40211
4 2232
5
私は、次のように取得するようにすぎないことを確認COL3に、最後の3桁の数字に基づいて分割する方法と、何でもCOL1に先行するだろう
col2 col3
0 25 021
1 25 002
2 8 002
3 40 211
4 2 232
5
クアンホアン:
これは私のアプローチです。
df['col2'] = df['col1'].astype(str).str[-3:]
df['col1'] = df['col1'].astype(str).str[:-3]
出力:
col1 col2
0 25 021
1 25 002
2 8 002
3 40 211
4 2 232