我有df
'date', 'ip', 'type_connection', 'user_agent', 'smth', 'type', 'weight', 'smth1', 'url'
1480394201 127.0.75.123:3000 CONNECT - 200 - 0 uic.login.skype.com:443 -
1480394202 127.0.75.123:3000 CONNECT - 200 - 0 uic.login.skype.com:443 -
1480394203 127.0.75.123:3000 CONNECT - 200 - 0 uic.login.skype.com:443 - -
1480395766 127.0.0.1 127.255.255.254:3000 CONNECT curl/7.38.0 200 - 0 google.com:443 -
1480395766 127.0.0.1 127.255.255.254:3000 HEAD curl/7.38.0 403 text/html 220 https://google.com/ -
我需要从列type_connection
中删除字符串,并将表的这一部分移到左侧
欲望输出
'date', 'ip', 'type_connection', 'user_agent', 'smth', 'type', 'weight', 'smth1', 'url'
1480394201 127.0.75.123:3000 CONNECT - 200 - 0 uic.login.skype.com:443 -
1480394202 127.0.75.123:3000 CONNECT - 200 - 0 uic.login.skype.com:443 -
1480394203 127.0.75.123:3000 CONNECT - 200 - 0 uic.login.skype.com:443 - -
1480395766 127.0.0.1 CONNECT curl/7.38.0 200 - 0 google.com:443 -
1480395766 127.0.0.1 HEAD curl/7.38.0 403 text/html 220 https://google.com/ -
我用
df.type_connection = np.where(df.type_connection.str.contains(':'), df.user_agent, df.type_connection)
但它只移动了一列user_agent