在Python中将管道分隔数据更改为数据帧
我有这样的管道分隔值:在Python中将管道分隔数据更改为数据帧,python,pandas,dataframe,Python,Pandas,Dataframe,我有这样的管道分隔值: https|clients4.google.com|application/octet-stream|2296| https|clients4.google.com|text/html; charset=utf-8|0| .... .... https|clients4.google.com|application/octet-stream|2291| 我必须用这些数据创建一个PandasDataFrame,每个列都有一个名称。给你: >>> impo
https|clients4.google.com|application/octet-stream|2296|
https|clients4.google.com|text/html; charset=utf-8|0|
....
....
https|clients4.google.com|application/octet-stream|2291|
我必须用这些数据创建一个PandasDataFrame
,每个列都有一个名称。给你:
>>> import pandas as pd
>>> pd.read_csv('data.csv', sep='|', index_col=False,
names=['protocol', 'server', 'type', 'value'])
Out[7]:
protocol server type value
0 https clients4.google.com application/octet-stream 2296
1 https clients4.google.com text/html; charset=utf-8 0
2 https clients4.google.com application/octet-stream 2291