I have a string list:
content
01/09/15, 10:07 - message1
01/09/15, 10:32 - message2
01/09/15, 10:44 - message3
I want a data frame, like:
date message
01/09/15, 10:07 message1
01/09/15, 10:32 message2
01/09/15, 10:44 message3
Considering the fact that all my strings in the list starts in that format, I can just split by -
, but I rather look for a smarter way to do so.
history = pd.DataFrame([line.split(" - ", 1) for line in content], columns=['date', 'message'])
(I'll convert the date to date time afterwards)
Any help would be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…