我有一列这样的内容:
id col1
1 223.237.181.234
2 236.235.183.239
3 247.254.167.267
4 238.252.153.236
5 202.237.145.252
现在,我想借助像这样的列中的点.
将这一列分为4列:
id col1_suffix1 col1_suffix2 col1_suffix3 col1_suffix4
1 223 237 181 234
2 236 235 183 239
3 247 254 167 267
答案 0 :(得分:1)
try this,
df[['col1_suffix1','col1_suffix2','col1_suffix3','col1_suffix4']]=df['col1'].str.split('.',expand=True)
O / P:
id col1 col1_suffix1 col1_suffix2 col1_suffix3 col1_suffix4
0 1 223.237.181.234 223 237 181 234
1 2 236.235.183.239 236 235 183 239
2 3 247.254.167.267 247 254 167 267
3 4 238.252.153.236 238 252 153 236
4 5 202.237.145.252 202 237 145 252