【发布时间】:2020-12-15 23:11:38
【问题描述】:
我有一个这样的字符串
"""PID TTY TIME CMD
1 ? 00:00:01 systemd
2 ? 00:00:00 kthreadd
3 ? 00:00:00 rcu_gp
4 ? 00:00:00 rcu_par_gp"""
现在我希望数据像data["PID"] 那样访问它,我会给我1,2,3,4 and so for other headers.
我使用pandas 和StringIO 将其转换为dataframe,但df.columns 的输出提供['PID TTY', 'TIME CMD'],这不是我想要的。
如果逻辑是python相关而不是pandas会更好
【问题讨论】:
-
不,这是一个错误。以某种方式将其删除。
标签: python python-3.x pandas list